I'm playing with std.json for the first time and didn't get how to parse these cases:
// case 1:
{}
// case 2:
{ "object": {}}
I tried this to handle the first case:
const std = @import("std");
pub fn main() !void {
const parsed = try std.json.parseFromSlice(void, std.heap.c_allocator,
\\{}
, .{});
std.log.debug("{any}", .{parsed.value});
}
But it gives:
zig run tmp.zig
/Users/timfayz/.zig/lib/std/json/static.zig:506:17: error: Unable to parse into type 'void'
else => @compileError("Unable to parse into type '" ++ @typeName(T) ++ "'"),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
parseFromTokenSourceLeaky__anon_6472: /Users/timfayz/.zig/lib/std/json/static.zig:140:33
parseFromTokenSource__anon_3419: /Users/timfayz/.zig/lib/std/json/static.zig:107:49
remaining reference traces hidden; use '-freference-trace' to see all reference traces