| ... | ... | @@ -623,7 +623,7 @@ pub const StreamingParser = struct { |
| 623 | 623 | |
| 624 | 624 | .ObjectSeparator => switch (c) { |
| 625 | 625 | ':' => { |
| 626 | | p.state = .ValueBegin; |
| 626 | p.state = .ValueBeginNoClosing; |
| 627 | 627 | p.after_string_state = .ValueEnd; |
| 628 | 628 | }, |
| 629 | 629 | 0x09, 0x0A, 0x0D, 0x20 => { |
| ... | ... | @@ -1205,6 +1205,13 @@ test "json.token mismatched close" { |
| 1205 | 1205 | try testing.expectError(error.UnexpectedClosingBrace, p.next()); |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | test "json.token premature object close" { |
| 1209 | var p = TokenStream.init("{ \"key\": }"); |
| 1210 | try checkNext(&p, .ObjectBegin); |
| 1211 | try checkNext(&p, .String); |
| 1212 | try testing.expectError(error.InvalidValueBegin, p.next()); |
| 1213 | } |
| 1214 | |
| 1208 | 1215 | /// Validate a JSON string. This does not limit number precision so a decoder may not necessarily |
| 1209 | 1216 | /// be able to decode the string even if this returns true. |
| 1210 | 1217 | pub fn validate(s: []const u8) bool { |