aboutsummaryrefslogtreecommitdiff
path: root/lib/std/json/stringify.zig
diff options
context:
space:
mode:
authorPhilipp Lühmann <philipp@luehmann.dev>2023-08-09 01:26:46 +0200
committerGitHub <noreply@github.com>2023-08-08 23:26:46 +0000
commitd34201c8491007c5a24b4175a5170a5b6cc3d55e (patch)
treeb1c5f230c9b143902acc17627b6e60a940cecc2e /lib/std/json/stringify.zig
parent36c57c3ba17c45a4c9b902041db9bb993dbc67b9 (diff)
downloadzig-d34201c8491007c5a24b4175a5170a5b6cc3d55e.tar.gz
zig-d34201c8491007c5a24b4175a5170a5b6cc3d55e.zip
std.json: stringify enum literals (#16742)
Diffstat (limited to 'lib/std/json/stringify.zig')
-rw-r--r--lib/std/json/stringify.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/std/json/stringify.zig b/lib/std/json/stringify.zig
index 1654da421c..41dfed4778 100644
--- a/lib/std/json/stringify.zig
+++ b/lib/std/json/stringify.zig
@@ -181,6 +181,7 @@ pub fn writeStreamArbitraryDepth(
/// * If the union declares a method `pub fn jsonStringify(self: *@This(), jw: anytype) !void`, it is called to do the serialization instead of the default behavior. The given `jw` is a pointer to this `WriteStream`.
/// * Zig `enum` -> JSON string naming the active tag.
/// * If the enum declares a method `pub fn jsonStringify(self: *@This(), jw: anytype) !void`, it is called to do the serialization instead of the default behavior. The given `jw` is a pointer to this `WriteStream`.
+/// * Zig untyped enum literal -> JSON string naming the active tag.
/// * Zig error -> JSON string naming the error.
/// * Zig `*T` -> the rendering of `T`. Note there is no guard against circular-reference infinite recursion.
///
@@ -449,7 +450,7 @@ pub fn WriteStream(
return try self.write(null);
}
},
- .Enum => {
+ .Enum, .EnumLiteral => {
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {
return value.jsonStringify(self);
}