Skip to content

Commit 6abcae1

Browse files
committed
Fix null array json converter.
1 parent 6c42f1f commit 6abcae1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main/java/com/github/underscore/lodash/Xml.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ private static Object checkArray(final Map<String, Object> map, final String nam
10871087
if (map.containsKey(ARRAY) && TRUE.equals(map.get(ARRAY))) {
10881088
final Map<String, Object> localMap4 = (Map) ((LinkedHashMap) localMap).clone();
10891089
localMap4.remove(ARRAY);
1090+
localMap4.remove(SELF_CLOSING);
10901091
object = name.equals(XmlValue.getMapKey(localMap4))
10911092
? U.newArrayList(Collections.singletonList(getValue(XmlValue.getMapValue(localMap4),
10921093
FromType.FOR_CONVERT)))

src/test/java/com/github/underscore/lodash/StringTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,18 @@ public void toJsonFromXml28() {
22652265
assertEquals(xml, U.toXml((Map<String, Object>) U.fromJson(json)));
22662266
}
22672267

2268+
@SuppressWarnings("unchecked")
2269+
@Test
2270+
public void toJsonFromXml29() {
2271+
final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2272+
+ "<root>\n"
2273+
+ " <element array=\"true\" null=\"true\"/>\n"
2274+
+ "</root>";
2275+
final String json = "[\n null\n]";
2276+
assertEquals(json, U.toJson((List<Object>) U.fromXml(xml)));
2277+
assertEquals(xml, U.toXml((List<Object>) U.fromJson(json)));
2278+
}
2279+
22682280
@SuppressWarnings("unchecked")
22692281
@Test
22702282
public void toXmlFromJson() {

0 commit comments

Comments
 (0)