mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
fix hello_json
This commit is contained in:
parent
5740b3b1a1
commit
23162dbe2e
1 changed files with 4 additions and 5 deletions
|
@ -75,12 +75,11 @@ pub fn toCharPtr(s: []const u8) [*c]u8 {
|
||||||
pub fn stringifyBuf(
|
pub fn stringifyBuf(
|
||||||
buffer: []u8,
|
buffer: []u8,
|
||||||
value: anytype,
|
value: anytype,
|
||||||
options: std.json.StringifyOptions,
|
options: std.json.Stringify.Options,
|
||||||
) ![]const u8 {
|
) ![]const u8 {
|
||||||
var fba = std.heap.FixedBufferAllocator.init(buffer);
|
var w: std.io.Writer = .fixed(buffer);
|
||||||
var string = std.ArrayList(u8).init(fba.allocator());
|
if (std.json.Stringify.value(value, options, &w)) {
|
||||||
if (std.json.stringify(value, options, string.writer())) {
|
return w.buffered();
|
||||||
return string.items;
|
|
||||||
} else |err| { // error
|
} else |err| { // error
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue