eclipse-ee4j / eclipse-ee4j/parsson

Inconsistency in JsonParser#hasNext()

Open
#24 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
17
Forks
25
PR merge metrics
No merged PRs in 30d

Description

`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 :confused: |
|2|{ |next();
hasNext(); // throws JsonParsingException |
|3|{"a" |next();
next();
hasNext(); // throws JsonParsingException |
|4|{"a": |next();
next();
hasNext(); // returns true :confused: |
|5|{"a":1 |next();
next();
next();
hasNext(); // throws JsonParsingException |
|6|{"a":1, |next();
next();
next();
hasNext(); // returns true :confused: |
|7|[ |next();
hasNext(); // throws JsonParsingException |
|8|[1 |next();
next();
hasNext(); // throws JsonParsingException |
|9|[1, |next();
next();
hasNext(); // returns true :confused: |

I believe for No.1, 4, 6, and 9 case, `hasNext()` should throw `JsonParsingException` instead of returning `true`.
Are these correct and intended bahavior?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.