Commit 89396ff02b
Changed files (2)
lib
std
lib/std/json/dynamic.zig
@@ -147,6 +147,12 @@ pub const Value = union(enum) {
}
}
}
+
+ pub fn jsonParseFromValue(allocator: Allocator, source: Value, options: ParseOptions) !@This() {
+ _ = allocator;
+ _ = options;
+ return source;
+ }
};
fn handleCompleteValue(stack: *Array, allocator: Allocator, source: anytype, value_: Value) !?Value {
lib/std/json/dynamic_test.zig
@@ -245,6 +245,23 @@ test "Value.jsonStringify" {
}
}
+test "parseFromValue(std.json.Value,...)" {
+ const str =
+ \\{
+ \\ "int": 32,
+ \\ "float": 3.2,
+ \\ "str": "str",
+ \\ "array": [3, 2],
+ \\ "object": {}
+ \\}
+ ;
+
+ const parsed_tree = try parseFromSlice(Value, testing.allocator, str, .{});
+ defer parsed_tree.deinit();
+ const tree = try parseFromValueLeaky(Value, parsed_tree.arena.allocator(), parsed_tree.value, .{});
+ try testing.expect(std.meta.eql(parsed_tree.value, tree));
+}
+
test "polymorphic parsing" {
if (true) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/16108
const doc =