Allow retaining null-valued bean properties in JSONObjects#983
Allow retaining null-valued bean properties in JSONObjects#983stleary merged 2 commits intostleary:masterfrom
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.
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.