-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
JSONArray converting incorrect input string to array #871
Comments
@ssharan27 Thanks for raising this issue. It turns out that since the beginning, the parser has been forgiving of unparseable content at the end of JSON docs. In this case, WIth this in mind, you can try some different variants and see if the results are consistent. |
Gotcha! Thanks @stleary ! This means I cannot rely on this constructor call alone to automatically detect a valid JSON (with strictness, that is) and then convert into array. The input needs to be validated before parsing. Is there any recommended way to do this? Also, would you consider adding examples as well where invalid JSON is parsed successfully in the docs or the readme itself? The docs do mention the forgiving nature but I think an example there would be helpful. I say this because a lot of examples/posts/SO answers I saw regarding this seem to ignore this behavior. |
No objections if someone wants to work on this.
|
…serConfiguration docs(stleary#871-strictMode): add javadoc
…tion test(stleary#871-strictMode): initial test implementation
Hi, I'm currently working on this and the only thing that is left to do is the quotes part and adding a few more unit tests. I will provide feedback as soon as I have more. |
…otes implementation
PR - #877 |
…or 1.6 compatibility
…rserConfiguration
…ements and simplification
test(stleary#871-strictMode): adjusted related tests, add more test cases for non-compliant quotes in strict mode
chore: removed PII from json sample chore: JSONParserConfiguration.java cleanup chore: JSONTokener.java nextValue partial rollback
Closing due to implementation completed. |
Hi, I recently came across a strange issue in one of my java applications. I have an input string that looks like
[1,2];[3,4]
. This is clearly not a JSON array and should result in an exception. However when I do the following:This gives me a List object with value
[1,2]
.I checked this in the latest release as well by adding the following test to the
JSONArrayTest
class and it still failed:I am not sure but it seems like the array object creation is stopping at the first
]
character even when there are characters left to read. Can you please take a look at this?The text was updated successfully, but these errors were encountered: