std: add support to std.json.stringify for null literals
This commit is contained in:
parent
62fbb6b874
commit
a32d88f12c
@ -1239,7 +1239,7 @@ pub const Value = union(enum) {
|
|||||||
out_stream: var,
|
out_stream: var,
|
||||||
) @TypeOf(out_stream).Error!void {
|
) @TypeOf(out_stream).Error!void {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
.Null => try out_stream.writeAll("null"),
|
.Null => try stringify(null, options, out_stream),
|
||||||
.Bool => |inner| try stringify(inner, options, out_stream),
|
.Bool => |inner| try stringify(inner, options, out_stream),
|
||||||
.Integer => |inner| try stringify(inner, options, out_stream),
|
.Integer => |inner| try stringify(inner, options, out_stream),
|
||||||
.Float => |inner| try stringify(inner, options, out_stream),
|
.Float => |inner| try stringify(inner, options, out_stream),
|
||||||
@ -2414,11 +2414,14 @@ pub fn stringify(
|
|||||||
.Bool => {
|
.Bool => {
|
||||||
return out_stream.writeAll(if (value) "true" else "false");
|
return out_stream.writeAll(if (value) "true" else "false");
|
||||||
},
|
},
|
||||||
|
.Null => {
|
||||||
|
return out_stream.writeAll("null");
|
||||||
|
},
|
||||||
.Optional => {
|
.Optional => {
|
||||||
if (value) |payload| {
|
if (value) |payload| {
|
||||||
return try stringify(payload, options, out_stream);
|
return try stringify(payload, options, out_stream);
|
||||||
} else {
|
} else {
|
||||||
return out_stream.writeAll("null");
|
return try stringify(null, options, out_stream);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.Enum => {
|
.Enum => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user