From b59bb17dcf799d5ed1a55377bbeaed21e3680407 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 30 May 2026 21:54:14 -0700 Subject: [PATCH] stringify: escape quotes too --- json.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/json.zig b/json.zig index 389502f90c45554d4d36516c1c48fb5c92dec61d..6f71db15eb2f1f2ebc8abeb12a2b487b2c0bc244 100644 --- a/json.zig +++ b/json.zig @@ -731,8 +731,10 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt try writer.writeAll("\""); for (value) |c| { try writer.writeAll(switch (c) { - 0x20...0x7e => &.{c}, 0x0c => "\\n", + 0x20...0x21 => &.{c}, + 0x22 => "\\\"", + 0x23...0x7e => &.{c}, else => "\\u00" ++ extras.to_hex([_]u8{c}), }); } @@ -751,8 +753,10 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt try writer.writeAll("\""); for (&value) |c| { try writer.writeAll(switch (c) { - 0x20...0x7e => &.{c}, 0x0c => "\\n", + 0x20...0x21 => &.{c}, + 0x22 => "\\\"", + 0x23...0x7e => &.{c}, else => "\\u00" ++ extras.to_hex([_]u8{c}), }); } -- 2.54.0