-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
new JSONPages try to parse the response entity as a JSON object rather than as arbitrary JSON
could solve sorta like:
super(httpResponse);
this.config = config;
JsonElement jsonElement = JsonParser.parse(httpResponse.getBody());
if(!json.isJsonArray()) {
json = jsonElement.toJsonElement();
JSONUtil.JsonQueryResponse queryResponse = JSONUtil.getJsonElementByPath(json, config.getResultPath());
insideElementJsonPathPart = queryResponse.getUnretrievedPath();
jsonElement = queryResponse.get();
}
if (jsonElement.isJsonArray()) {
iterator = queryResponse.getAsJsonArray().iterator();
} else if (jsonElement.isJsonObject()) {
iterator = Collections.singleton(jsonElement).iterator();
} else {
throw new IllegalArgumentException(String.format("Element found by '%s' json path is expected to be an object " +
"or an array. Primitive found", config.getResultPath()));
}
fieldsMapping = config.getFullFieldsMapping();
schema = config.getSchema();
Metadata
Metadata
Assignees
Labels
No labels