Fix bug handling null objects in JSON (R5)

This commit is contained in:
Grahame Grieve 2023-12-22 21:15:08 +11:00
parent 1cdcfb3396
commit cf4a970e47
2 changed files with 1944 additions and 1933 deletions

View File

@ -176,6 +176,17 @@ public abstract class JsonParserBase extends ParserBase implements IParser {
return (JsonArray) j;
}
protected JsonObject getJsonObjectFromArray(JsonArray array, int i) throws IOException {
JsonElement e = array.get(i);
if (e.isJsonObject()) {
return (JsonObject) e;
}
if (e.isJsonNull()) {
return new JsonObject();
}
throw new IOException("Array item "+i+" is a "+e.getClass()+" looking for an Object");
}
/**
* Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)
* @throws IOException