mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 11:34:43 +08:00
Test case passed with tags with multiple entries set forceList
This commit is contained in:
@@ -380,12 +380,23 @@ public class XML {
|
||||
if (x.nextToken() != GT) {
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if (nilAttributeFound) {
|
||||
context.accumulate(tagName, JSONObject.NULL);
|
||||
} else if (jsonObject.length() > 0) {
|
||||
context.accumulate(tagName, jsonObject);
|
||||
if (config.getForceList().contains(tagName)) {
|
||||
// Force the value to be an array
|
||||
if (nilAttributeFound) {
|
||||
context.append(tagName, JSONObject.NULL);
|
||||
} else if (jsonObject.length() > 0) {
|
||||
context.append(tagName, jsonObject);
|
||||
} else {
|
||||
context.put(tagName, new JSONArray());
|
||||
}
|
||||
} else {
|
||||
context.accumulate(tagName, "");
|
||||
if (nilAttributeFound) {
|
||||
context.accumulate(tagName, JSONObject.NULL);
|
||||
} else if (jsonObject.length() > 0) {
|
||||
context.accumulate(tagName, jsonObject);
|
||||
} else {
|
||||
context.accumulate(tagName, "");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -414,6 +425,7 @@ public class XML {
|
||||
// Nested element
|
||||
if (parse(x, jsonObject, tagName, config)) {
|
||||
if (config.getForceList().contains(tagName)) {
|
||||
// Force the value to be an array
|
||||
if (jsonObject.length() == 0) {
|
||||
context.put(tagName, new JSONArray());
|
||||
} else if (jsonObject.length() == 1
|
||||
|
Reference in New Issue
Block a user