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...@@ -731,8 +731,10 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt
731 try writer.writeAll("\"");731 try writer.writeAll("\"");
732 for (value) |c| {732 for (value) |c| {
733 try writer.writeAll(switch (c) {733 try writer.writeAll(switch (c) {
734 0x20...0x7e => &.{c},
735 0x0c => "\\n",734 0x0c => "\\n",
735 0x20...0x21 => &.{c},
736 0x22 => "\\\"",
737 0x23...0x7e => &.{c},
736 else => "\\u00" ++ extras.to_hex([_]u8{c}),738 else => "\\u00" ++ extras.to_hex([_]u8{c}),
737 });739 });
738 }740 }
...@@ -751,8 +753,10 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt...@@ -751,8 +753,10 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt
751 try writer.writeAll("\"");753 try writer.writeAll("\"");
752 for (&value) |c| {754 for (&value) |c| {
753 try writer.writeAll(switch (c) {755 try writer.writeAll(switch (c) {
754 0x20...0x7e => &.{c},
755 0x0c => "\\n",756 0x0c => "\\n",
757 0x20...0x21 => &.{c},
758 0x22 => "\\\"",
759 0x23...0x7e => &.{c},
756 else => "\\u00" ++ extras.to_hex([_]u8{c}),760 else => "\\u00" ++ extras.to_hex([_]u8{c}),
757 });761 });
758 }762 }