Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/com/github/underscore/U.java
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,8 @@ public static FetchResponse fetch(
}
}

public static int readWithRetry(java.io.InputStream inputStream, byte[] buffer) throws java.io.IOException {
public static int readWithRetry(java.io.InputStream inputStream, byte[] buffer)
throws java.io.IOException {
java.io.IOException lastException = null;
for (int attempt = 0; attempt < 2; attempt++) {
try {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/github/underscore/Xml.java
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,8 @@ private static void checkLocalMap(
|| localMap2.size() != 1
|| XmlValue.getMapKey(localMap2).startsWith("-")
|| XmlValue.getMapValue(localMap2) instanceof List) {
if (ROOT.equals(XmlValue.getMapKey(localMap2))) {
if (ROOT.equals(XmlValue.getMapKey(localMap2))
&& XmlValue.getMapValue(localMap2) instanceof List) {
writeArray((List) XmlValue.getMapValue(localMap2), builder, arrayTrue);
} else {
XmlObject.writeXml(
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/com/github/underscore/LodashTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,24 @@ void xmpToJson5() {
U.xmlToJson("<Comment stringValue=\"============================\"/>"));
}

@Test
void xmpToJson6() {
assertEquals(
"{\n"
+ " \"root\": {\n"
+ " \"a\": 1\n"
+ " },\n"
+ " \"omit-xml-declaration\": \"yes\"\n"
+ "}",
U.xmlToJson("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<root>\n"
+ " <root>\n"
+ " <a number=\"true\">1</a>\n"
+ " </root>\n"
+ " <omit-xml-declaration>yes</omit-xml-declaration>\n"
+ "</root>"));
}

@Test
void xmlToJsonMinimum() {
assertEquals(
Expand Down
Loading