You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSONObject and JSONArray initial flag for tokener may be flawed #944
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?
@Md-Yasir This might be a tough issue to start with; there may not be a solution that works without breaking existing functionality.
You are also welcome to start working on some issues that are more approachable. SonarQube has listed > 1000 issues to be addressed. Most of them are in the test files and not a priority. But about 100 issues are in the production code. Most are easy to fix and test. A few will need to be marked as false positive.
After viewing the current code in master branch, I found that the isInitial variable is used to determine whether the object/array is the root, and to determine whether to throw the error.
I have an immature idea: why not just use the current index of the tokener?
Hmm, I will test this locally. If it passes the test suite, and hopefully, doesn't break the compatibility, maybe I can open a pull request for reviewing.
After viewing the current code in master branch, I found that the isInitial variable is used to determine whether the object/array is the root, and to determine whether to throw the error.
I have an immature idea: why not just use the current index of the tokener?
Hmm, I will test this locally. If it passes the test suite, and hopefully, doesn't break the compatibility, maybe I can open a pull request for reviewing.
Activity
Md-Yasir commentedon Oct 11, 2025
I am looking into this @stleary and this is going to be my first open-source contribution. 😙
stleary commentedon Oct 11, 2025
@Md-Yasir This might be a tough issue to start with; there may not be a solution that works without breaking existing functionality.
You are also welcome to start working on some issues that are more approachable. SonarQube has listed > 1000 issues to be addressed. Most of them are in the test files and not a priority. But about 100 issues are in the production code. Most are easy to fix and test. A few will need to be marked as false positive.
All Open issues
To help get you started, this is how previous work has gone:
False positives (Don't work on these type of issues)
Fixed (How similar issues were fixed)
Md-Yasir commentedon Oct 11, 2025
Got it, So should I use Github or sonarqube for the updates? I haven't used sonarqube yet. Thanks
stleary commentedon Oct 11, 2025
All work should be done in GitHub. Just use SonarQube as a reporting tool, to identify the issues to fix.
Md-Yasir commentedon Oct 11, 2025
Understood.. Here is my first pull req
XIAYM-gh commentedon Sep 2, 2026
After viewing the current code in
masterbranch, I found that theisInitialvariable is used to determine whether the object/array is the root, and to determine whether to throw the error.I have an immature idea: why not just use the current index of the tokener?
Hmm, I will test this locally. If it passes the test suite, and hopefully, doesn't break the compatibility, maybe I can open a pull request for reviewing.
XIAYM-gh commentedon Sep 2, 2026
Well, no. This changes the internal behaviour!
I will search for a more reasonable solution...