hasNext() method in JsonParser provided by the Reference Implementation does not behave consistently for unterminated JSON.
Please see the following results.
| No. |
JSON to parse |
Result of hasNext() |
| 1 |
(empty) |
hasNext(); // returns true 😕 |
| 2 |
{ |
next(); hasNext(); // throws JsonParsingException |
| 3 |
{"a" |
next(); next(); hasNext(); // throws JsonParsingException |
| 4 |
{"a": |
next(); next(); hasNext(); // returns true 😕 |
| 5 |
{"a":1 |
next(); next(); next(); hasNext(); // throws JsonParsingException |
| 6 |
{"a":1, |
next(); next(); next(); hasNext(); // returns true 😕 |
| 7 |
[ |
next(); hasNext(); // throws JsonParsingException |
| 8 |
[1 |
next(); next(); hasNext(); // throws JsonParsingException |
| 9 |
[1, |
next(); next(); hasNext(); // returns true 😕 |
I believe for No.1, 4, 6, and 9 case, hasNext() should throw JsonParsingException instead of returning true.
Are these correct and intended bahavior?
hasNext()method inJsonParserprovided by the Reference Implementation does not behave consistently for unterminated JSON.Please see the following results.
hasNext(); // throws JsonParsingException
next();
hasNext(); // throws JsonParsingException
next();
hasNext(); // returns true 😕
next();
next();
hasNext(); // throws JsonParsingException
next();
next();
hasNext(); // returns true 😕
hasNext(); // throws JsonParsingException
next();
hasNext(); // throws JsonParsingException
next();
hasNext(); // returns true 😕
I believe for No.1, 4, 6, and 9 case,
hasNext()should throwJsonParsingExceptioninstead of returningtrue.Are these correct and intended bahavior?