-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonPaser#getString() returns wrong value #7
Comments
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented 13, not: "13a":1 |
@glassfishrobot Commented 13 would be acceptable as long as an additional call to parser.next() raises a parse error since the input is missing the final right curly bracket. |
@glassfishrobot Commented and an extra parser.next() throw exception like: So I will close the bug, do you agree? |
@glassfishrobot Commented https://json-processing-spec.java.net/nonav/releases/1.0/pfd-draft/javadocs/javax/json/stream/JsonParser.html#next( Most parsers would give a message like "Unexpected end of input. Expected '}' or ','" Or something like this. And ideally this message would include the line and column where the error was encountered. |
@glassfishrobot Commented |
@m0mus Commented |
|
Right now this test is passing: public void testIssue7() {
JsonParser parser = Json.createParser(new StringReader("{\"a\":13"));
parser.next();
parser.next();
parser.next();
assertEquals("13", parser.getString());
try {
parser.next();
fail("Error expected");
} catch (JsonParsingException e) {}
} It looks correct to my eyes. |
The reference implementation fails to raise an error when the input JSON is invalid. Here is a reproducer:
JsonParser parser = Json.createParser(new StringReader("{"a":13"));
parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.next(); // VALUE_NUMBER
System.out.println(parser.getString()); // "13a":1
Environment
JDK7
Affected Versions
[1.0.4]
The text was updated successfully, but these errors were encountered: