Skip to content

JSONArray.parse() - JSONArray of JSONObjects crashes #1680

Description

@agoransson

There are two JSONTokener classes, one static inside JSONObject. This inner class causes the parsing to use the JSONObject(Object bean) constructor instead of the JSONObject(JSONTokener) constructor - which is not the intended behavious I'm sure.

When I removed the static class inside JSONObject it seemed to work fine; however, I haven't made more tests than on a JSONArray of JSONObject's.

Test sketch:
String json_1 = "[1,2,3,4]";
String json_2 = "[{"a":"1"},{"b":"2"}]";
//JSONTokener token = new JSONTokener(json_2);
//JSONArray arr = new JSONArray(token);
JSONArray arr = JSONArray.parse(json_2);
println( arr );

error:
java.lang.RuntimeException: Expected a ',' or ']'
at processing.data.JSONArray.(JSONArray.java:136)
null
at processing.data.JSONArray.parse(JSONArray.java:152)
at json_tests.setup(json_tests.java:22)
at processing.core.PApplet.handleDraw(PApplet.java:2241)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243)
at processing.core.PApplet.run(PApplet.java:2140)
at java.lang.Thread.run(Thread.java:662)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions