aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jv/stringify.zig2
-rw-r--r--src/root.zig28
2 files changed, 25 insertions, 5 deletions
diff --git a/src/jv/stringify.zig b/src/jv/stringify.zig
index 341fed3..b553c6b 100644
--- a/src/jv/stringify.zig
+++ b/src/jv/stringify.zig
@@ -2,5 +2,5 @@ const std = @import("std");
const Value = @import("./value.zig").Value;
pub fn stringify(allocator: std.mem.Allocator, value: Value) ![]u8 {
- return try std.json.Stringify.valueAlloc(allocator, value, .{});
+ return try std.json.Stringify.valueAlloc(allocator, value, .{ .whitespace = .indent_2 });
}
diff --git a/src/root.zig b/src/root.zig
index 6cdc276..123dc7e 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -61,8 +61,18 @@ test "identity filter" {
try testRun("3.1415", "3.1415", ".");
try testRun("[]", "[]", ".");
try testRun("{}", "{}", ".");
- try testRun("[1,2,3]", "[1,2,3]", ".");
- try testRun("{\"a\":123}", "{\"a\":123}", ".");
+ try testRun(
+ \\[
+ \\ 1,
+ \\ 2,
+ \\ 3
+ \\]
+ , "[1,2,3]", ".");
+ try testRun(
+ \\{
+ \\ "a": 123
+ \\}
+ , "{\"a\":123}", ".");
}
test "index access" {
@@ -81,8 +91,18 @@ test "index access" {
try testRun("123", "{\"a\":123}", ".a");
try testRun("null", "{\"a\":123}", ".b");
try testRun("\"hello\"", "{\"foo\":\"hello\"}", ".foo");
- try testRun("[1,2,3]", "{\"arr\":[1,2,3]}", ".arr");
- try testRun("{\"bar\":true}", "{\"foo\":{\"bar\":true}}", ".foo");
+ try testRun(
+ \\[
+ \\ 1,
+ \\ 2,
+ \\ 3
+ \\]
+ , "{\"arr\":[1,2,3]}", ".arr");
+ try testRun(
+ \\{
+ \\ "bar": true
+ \\}
+ , "{\"foo\":{\"bar\":true}}", ".foo");
try testRun("123", "{\"a\":123}", ".[\"a\"]");
try testRun("null", "{\"a\":123}", ".[\"b\"]");