| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -428,6 +428,9 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, XMLP | |||
| 428 | 428 | config.isKeepNumberAsString() | |
| 429 | 429 | ? ((String) token) | |
| 430 | 430 | : obj); | |
| 431 | + } else if (obj == JSONObject.NULL) { | ||
| 432 | + jsonObject.accumulate(config.getcDataTagName(), | ||
| 433 | + config.isKeepStrings() ? ((String) token) : obj); | ||
| 431 | 434 | } else { | |
| 432 | 435 | jsonObject.accumulate(config.getcDataTagName(), stringToValue((String) token)); | |
| 433 | 436 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -794,6 +794,18 @@ public void testToJSONArray_jsonOutput_withKeepBooleanAsString() { | |||
| 794 | 794 | Util.compareActualVsExpectedJsonObjects(actualJsonOutput,expected); | |
| 795 | 795 | } | |
| 796 | 796 | ||
| 797 | + /** | ||
| 798 | + * null is "null" when keepStrings == true | ||
| 799 | + */ | ||
| 800 | + @Test | ||
| 801 | + public void testToJSONArray_jsonOutput_null_withKeepString() { | ||
| 802 | + final String originalXml = "<root><id>01</id><id>1</id><id>00</id><id>0</id><item id=\"01\"/><title>null</title></root>"; | ||
| 803 | + final JSONObject expected = new JSONObject("{\"root\":{\"item\":{\"id\":\"01\"},\"id\":[\"01\",\"1\",\"00\",\"0\"],\"title\":\"null\"}}"); | ||
| 804 | + final JSONObject actualJsonOutput = XML.toJSONObject(originalXml, | ||
| 805 | + new XMLParserConfiguration().withKeepStrings(true)); | ||
| 806 | + Util.compareActualVsExpectedJsonObjects(actualJsonOutput,expected); | ||
| 807 | + } | ||
| 808 | + | ||
| 797 | 809 | /** | |
| 798 | 810 | * Test keepStrings behavior when setting keepBooleanAsString, keepNumberAsString | |
| 799 | 811 | */ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments