authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-24 03:42:04 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-24 03:42:04 -07:00
log80e943ac8734b91da3560c8f45bbe702d833ac11
tree59b0484b1bc11456db94d520e65767bdf2e25700
parentc53591303599ccf2f676adfaa9c7b6a16204fd98
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add stringifyAlloc


1 files changed, 8 insertions(+), 0 deletions(-)

json.zig+8
......@@ -765,3 +765,11 @@ pub fn stringify(writer: anytype, value: anytype, options: std.json.StringifyOpt
765765 else => @compileError(@typeName(T)),
766766 }
767767}
768
769pub fn stringifyAlloc(allocator: std.mem.Allocator, value: anytype, options: std.json.StringifyOptions) ![]u8 {
770 var writer: nio.AllocatingWriter = .init(allocator);
771 defer writer.deinit();
772 try writer.ensureUnusedCapacity(256);
773 try stringify(&writer, value, options);
774 return writer.toOwnedSlice();
775}