in org.apache.sling.graphql.samples.website/src/main/java/org/apache/sling/scripting/handlebars/HandlebarsScriptEngine.java [90:109]
private Map<?, ?> getData(Resource r) throws ScriptException {
// Request resource.json and convert the result to Maps
String jsonString = null;
try {
jsonString =
new ServletInternalRequest(factory.getServletResolver(), r)
.withExtension("json")
.execute()
.getResponseAsString()
;
} catch(Exception e) {
final ScriptException up = new ScriptException("Internal request failed");
up.initCause(e);
log.info("getData() failed", up);
throw up;
}
final Map<?, ?> result = JsonReader.jsonToMaps(jsonString);
log.debug("getData() returns a Map with {} keys", result.keySet().size());
return result;
}