authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 21:54:14 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 21:54:14 -07:00
logb59bb17dcf799d5ed1a55377bbeaed21e3680407
tree2f151b4025c24369bd0243c91a0ca41da17aa778
parente789611498c56f074447733083e3a629c4b2b947
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

stringify: escape quotes too


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

json.zig+6-2
......@@ -731,8 +731,10 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt
731731 try writer.writeAll("\"");
732732 for (value) |c| {
733733 try writer.writeAll(switch (c) {
734 0x20...0x7e => &.{c},
735734 0x0c => "\\n",
735 0x20...0x21 => &.{c},
736 0x22 => "\\\"",
737 0x23...0x7e => &.{c},
736738 else => "\\u00" ++ extras.to_hex([_]u8{c}),
737739 });
738740 }
......@@ -751,8 +753,10 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt
751753 try writer.writeAll("\"");
752754 for (&value) |c| {
753755 try writer.writeAll(switch (c) {
754 0x20...0x7e => &.{c},
755756 0x0c => "\\n",
757 0x20...0x21 => &.{c},
758 0x22 => "\\\"",
759 0x23...0x7e => &.{c},
756760 else => "\\u00" ++ extras.to_hex([_]u8{c}),
757761 });
758762 }