-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use JSONParserConfiguration to decide on serializing Null fields into JSONObject #982 #983
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
Conversation
|
@harshith8854 SonarCloud code analysis is still experimental; you can ignore those results. |
| JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration(); | ||
| RecursiveBean bean = new RecursiveBean(null); | ||
| JSONObject jsonObject = new JSONObject(bean, jsonParserConfiguration.withUseNativeNulls(true)); | ||
| String textStr = jsonObject.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of converting to text, the jsonObject should be checked directly. For example,
assertTrue("missing name key", jsonObject.has("name"));
assertEquals("wrong name value", jsonObject.optString("name", "wrong"), null);
|
What problem does this code solve? Does the code still compile with Java6? Risks Changes to the API? Will this require a new release? Should the documentation be updated? Does it break the unit tests? Was any code refactored in this commit? Review status 3-day comment window started Note: There were 2 minor comments for the unit tests. Please fix them if you have time. Otherwise, I will include a fix in the #984 issue |
|
Sure, let me work on them |
|




This commit includes changes to consider JSONParserConfiguration.isUseNativeNulls() to decide if a null field to be serialized or not corresponding to issue #982
Also, includes the test case to test the same.