aboutsummaryrefslogtreecommitdiff
path: root/lib/std/json.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/json.zig')
-rw-r--r--lib/std/json.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/std/json.zig b/lib/std/json.zig
index ed26c13229..7515f8682d 100644
--- a/lib/std/json.zig
+++ b/lib/std/json.zig
@@ -623,7 +623,7 @@ pub const StreamingParser = struct {
.ObjectSeparator => switch (c) {
':' => {
- p.state = .ValueBegin;
+ p.state = .ValueBeginNoClosing;
p.after_string_state = .ValueEnd;
},
0x09, 0x0A, 0x0D, 0x20 => {
@@ -1205,6 +1205,13 @@ test "json.token mismatched close" {
try testing.expectError(error.UnexpectedClosingBrace, p.next());
}
+test "json.token premature object close" {
+ var p = TokenStream.init("{ \"key\": }");
+ try checkNext(&p, .ObjectBegin);
+ try checkNext(&p, .String);
+ try testing.expectError(error.InvalidValueBegin, p.next());
+}
+
/// Validate a JSON string. This does not limit number precision so a decoder may not necessarily
/// be able to decode the string even if this returns true.
pub fn validate(s: []const u8) bool {