use of org.apache.sling.commons.json.jcr.JsonItemWriter in project acs-aem-commons by Adobe-Consulting-Services.
the class AbstractWidgetConfigurationServlet method toJSONObject.
protected JSONObject toJSONObject(Resource resource) throws JSONException, ServletException {
JSONObject config = null;
Node node = resource.adaptTo(Node.class);
if (node != null) {
JsonItemWriter writer = new JsonItemWriter(null);
StringWriter string = new StringWriter();
try {
writer.dump(node, string, -1);
} catch (RepositoryException e) {
throw new ServletException(e);
}
config = new JSONObject(string.toString());
}
return config;
}
Aggregations