aboutsummaryrefslogtreecommitdiff
path: root/lib/std/json.zig
diff options
context:
space:
mode:
authorDmitry Atamanov <data-man@users.noreply.github.com>2020-05-29 08:10:16 +0500
committerGitHub <noreply@github.com>2020-05-28 23:10:16 -0400
commit0328537ca641e0b24218f303c7a1bf0440cd7115 (patch)
tree5e4f09ef0bb5b8e897a77447ab7a81c75b17e1c3 /lib/std/json.zig
parent8630ae7523362e00efe9cc914cf05dcef09c3500 (diff)
downloadzig-0328537ca641e0b24218f303c7a1bf0440cd7115.tar.gz
zig-0328537ca641e0b24218f303c7a1bf0440cd7115.zip
Support stringify for vectors (#5441)
* use array's pointer
Diffstat (limited to 'lib/std/json.zig')
-rw-r--r--lib/std/json.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/std/json.zig b/lib/std/json.zig
index 095a446d00..eeceeac8a7 100644
--- a/lib/std/json.zig
+++ b/lib/std/json.zig
@@ -2575,6 +2575,10 @@ pub fn stringify(
else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),
},
.Array => return stringify(&value, options, out_stream),
+ .Vector => |info| {
+ const array: [info.len]info.child = value;
+ return stringify(&array, options, out_stream);
+ },
else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),
}
unreachable;
@@ -2762,3 +2766,8 @@ test "stringify struct with custom stringifier" {
}
}{ .foo = 42 }, StringifyOptions{});
}
+
+test "stringify vector" {
+ try teststringify("[1,1]", @splat(2, @as(u32, 1)), StringifyOptions{});
+}
+