Skip to content

JSONObject and JSONArray initial flag for tokener may be flawed #944

Description

@stleary

From #927:

The boolean isInitial = x.getPrevious() == 0; check can behave in an unexpected way, for example:
JSONParserConfiguration strict = new JSONParserConfiguration().withStrictMode();
JSONTokener tok = new JSONTokener("[]xxx");
// Calling next+back changes "previous"; without these calls the check is performed:
tok.next();
tok.back();
JSONArray a1 = new JSONArray(tok, strict); // No error here, but should be because of extra chars?

This is a far corner case I think, but should be fixed if practical.
Is there a way to capture this in the JSONTokener object?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions