authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-02-25 20:37:48+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-04-01 00:12:59+11:00
loga32d88f12c65b48c8861748f0879bcb1b5be61d0
tree342397fe9c5187c2b269ac311f7616c10c8c2675
parent62fbb6b87406d8dd0b256ca42246b86972cd2faf
signature Commit is signed but in an unrecognized format.

std: add support to std.json.stringify for null literals


1 files changed, 5 insertions(+), 2 deletions(-)

lib/std/json.zig+5-2
......@@ -1239,7 +1239,7 @@ pub const Value = union(enum) {
12391239 out_stream: var,
12401240 ) @TypeOf(out_stream).Error!void {
12411241 switch (value) {
1242 .Null => try out_stream.writeAll("null"),
1242 .Null => try stringify(null, options, out_stream),
12431243 .Bool => |inner| try stringify(inner, options, out_stream),
12441244 .Integer => |inner| try stringify(inner, options, out_stream),
12451245 .Float => |inner| try stringify(inner, options, out_stream),
......@@ -2414,11 +2414,14 @@ pub fn stringify(
24142414 .Bool => {
24152415 return out_stream.writeAll(if (value) "true" else "false");
24162416 },
2417 .Null => {
2418 return out_stream.writeAll("null");
2419 },
24172420 .Optional => {
24182421 if (value) |payload| {
24192422 return try stringify(payload, options, out_stream);
24202423 } else {
2421 return out_stream.writeAll("null");
2424 return try stringify(null, options, out_stream);
24222425 }
24232426 },
24242427 .Enum => {