Skip to content

Commit a0f90b7

Browse files
author
Zach
committed
Passed simple test
1 parent fafaeb7 commit a0f90b7

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/main/java/org/json/XML.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,26 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, XMLP
413413
} else if (token == LT) {
414414
// Nested element
415415
if (parse(x, jsonObject, tagName, config)) {
416-
if (jsonObject.length() == 0) {
417-
context.accumulate(tagName, "");
418-
} else if (jsonObject.length() == 1
419-
&& jsonObject.opt(config.getcDataTagName()) != null) {
420-
context.accumulate(tagName, jsonObject.opt(config.getcDataTagName()));
416+
if (config.getForceList().contains(tagName)) {
417+
if (jsonObject.length() == 0) {
418+
context.append(tagName, "");
419+
} else if (jsonObject.length() == 1
420+
&& jsonObject.opt(config.getcDataTagName()) != null) {
421+
context.append(tagName, jsonObject.opt(config.getcDataTagName()));
422+
} else {
423+
context.append(tagName, jsonObject);
424+
}
421425
} else {
422-
context.accumulate(tagName, jsonObject);
426+
if (jsonObject.length() == 0) {
427+
context.accumulate(tagName, "");
428+
} else if (jsonObject.length() == 1
429+
&& jsonObject.opt(config.getcDataTagName()) != null) {
430+
context.accumulate(tagName, jsonObject.opt(config.getcDataTagName()));
431+
} else {
432+
context.accumulate(tagName, jsonObject);
433+
}
423434
}
435+
424436
return false;
425437
}
426438
}

0 commit comments

Comments
 (0)