Skip to content

Parsing a sequence of JSON values that are not enclosed in a JSON array #14

@tomwhoiscontrary

Description

@tomwhoiscontrary

Joy is described as being:

Fully compliant with the latest specification of Jakarta JSON Processing API.

In the latest specification, the documentation for JsonParser says:

JsonParser can be used to parse sequence of JSON values that are not enclosed in a JSON array, e.g. { } { }. The following code demonstrates how to parse such sequence.

JsonParser parser = Json.createParser(...);
while (parser.hasNext) {
parser.next(); // advance parser state
JsonValue value = parser.getValue();
}

The "following code" there is not quite syntactically correct, but i think the intent is clear.

However, the code in the documentation (my version), run on the input in the documentation, using Joy 2.1.0, does not work - it throws an exception:

jakarta.json.stream.JsonParsingException: [line=1,column=5,offset=4] Unexpected char '{' was found.

	at org.leadpony.joy.core.BasicJsonParser.newUnexpectedCharException(BasicJsonParser.java:778)
	at org.leadpony.joy.core.BasicJsonParser$State$2.accepts(BasicJsonParser.java:820)
	at org.leadpony.joy.core.BasicJsonParser.hasNext(BasicJsonParser.java:97)

I have tried this with Glassfish Jaka 1.1.6 (not the latest), and it fails in much the same way.

Should it be possible to parse multiple top-level JSON values like this?

If so, is this a bug in Joy?

If not, is this a bug in the API documentation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions