fix bug validating json primitives that repeat
This commit is contained in:
parent
d77b687d95
commit
c0c5b7f7ac
|
@ -253,7 +253,17 @@ public class JsonParser extends ParserBase {
|
||||||
JsonElement main = object.has(name) ? object.get(name) : null;
|
JsonElement main = object.has(name) ? object.get(name) : null;
|
||||||
JsonElement fork = object.has("_"+name) ? object.get("_"+name) : null;
|
JsonElement fork = object.has("_"+name) ? object.get("_"+name) : null;
|
||||||
if (main != null || fork != null) {
|
if (main != null || fork != null) {
|
||||||
if (property.isList() && ((main == null) || (main instanceof JsonArray)) &&((fork == null) || (fork instanceof JsonArray)) ) {
|
if (property.isList()) {
|
||||||
|
boolean ok = true;
|
||||||
|
if (!(main == null || main instanceof JsonArray)) {
|
||||||
|
logError(line(main), col(main), npath, IssueType.INVALID, "This property must be an Array, not a "+describe(main), IssueSeverity.ERROR);
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
if (!(fork == null || fork instanceof JsonArray)) {
|
||||||
|
logError(line(fork), col(fork), npath, IssueType.INVALID, "This base property must be an Array, not a "+describe(main), IssueSeverity.ERROR);
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
JsonArray arr1 = (JsonArray) main;
|
JsonArray arr1 = (JsonArray) main;
|
||||||
JsonArray arr2 = (JsonArray) fork;
|
JsonArray arr2 = (JsonArray) fork;
|
||||||
for (int i = 0; i < Math.max(arrC(arr1), arrC(arr2)); i++) {
|
for (int i = 0; i < Math.max(arrC(arr1), arrC(arr2)); i++) {
|
||||||
|
@ -261,10 +271,12 @@ public class JsonParser extends ParserBase {
|
||||||
JsonElement f = arrI(arr2, i);
|
JsonElement f = arrI(arr2, i);
|
||||||
parseChildPrimitiveInstance(context, property, name, npath, m, f);
|
parseChildPrimitiveInstance(context, property, name, npath, m, f);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
parseChildPrimitiveInstance(context, property, name, npath, main, fork);
|
parseChildPrimitiveInstance(context, property, name, npath, main, fork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private JsonElement arrI(JsonArray arr, int i) {
|
private JsonElement arrI(JsonArray arr, int i) {
|
||||||
return arr == null || i >= arr.size() || arr.get(i) instanceof JsonNull ? null : arr.get(i);
|
return arr == null || i >= arr.size() || arr.get(i) instanceof JsonNull ? null : arr.get(i);
|
||||||
|
|
Loading…
Reference in New Issue