| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…issing all JSONObject test cases and strict mode sanity check. Might be able to simplify implementation a bit more
…semicolon instead of colon separator in object
…de default is true
With current JSON library we can switch to use JSON parser configuration with strict mode. See: https://github.com/stleary/JSON-java/releases/tag/20241224 stleary/JSON-java#921 Change-Id: Ib689f144a9f28f37e113c550646fe8640257cc79 Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
With current JSON library we can switch to use JSON parser configuration with strict mode. See: https://github.com/stleary/JSON-java/releases/tag/20241224 stleary/JSON-java#921 Change-Id: Ib689f144a9f28f37e113c550646fe8640257cc79 Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech> (cherry picked from commit e490c19)
| Back | FazBrowse Home | New Git URL |
What problem does this code solve?
The default JSON-Java library is quite permissive in allowing invalid JSON docs to be parsed successfully. The "strict mode" feature is for users who need the library to enforce valid JSON text.
A few months ago, strict mode was added but it was not fully completed. As a result, the code was backed out temporarily and is now restored, with some updates to complete the implementation.
Strict mode is only available when parsing JSON from a text document.
To enable strict mode, use code like the following:
JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration() .withStrictMode(true); JSONObject jsonObject = new JSONObject(myString, jsonParserConfiguration));What exactly is excluded in strict mode:
To test for regressions, update the JSONParserConfiguration class to have strict mode enabled by default. Then build the project and run the unit tests, which should all complete successfully.
Does the code still compile with Java6?
Yes
Risks
Low
Changes to the API?
The original strict mode API has been restored.
Will this require a new release?
No
Should the documentation be updated?
No
Does it break the unit tests?
No. Some tests that used invalid JSON text have been fixed. A few tests that specifically use invalid text are skipped when strict mode is defaulted. (see regression testing discussion above). New unit tests were added.
Was any code refactored in this commit?
The internal implementation of strict mode has been updated.
Review status
APPROVED - by myself
Starting 3-day comment window