I've noticed this too.

From tracing through the code, I think the problem starts when writing out non-JCR Resources (like BundleResource or SyntheticResource). The dump(Resource, JSONWriter,int, int) method of JsonResourceWriter tries to adapt the given Resource to ValueMap, then a Map and finally a String. Those non-JCR Resources don't adapt to any of these, so the method just returns, rather than executing a JSONWriter.object()/JSONWriter.endObject() pair. I think this leaves the JSONWriter in the incorrect mode (set to 'o' in JSONWriter.key call at line 136), causing the failure on the subsequent node dump.

If you have the dojo bundle installed (which renders the dojo javascript files as BundleResources) & try to dump http://localhost:8888/dojo.1.json, you'll see it renders the first file (AdapaterRegistry.js), but fails on the next. Unfortunately, I don't know enough about how this code is supposed to work to suggest a fix. Maybe those non-JCR resources should be adaptable to ValueMap or Map?

Regards,
Rory

Torgeir Veimo wrote:
Using http://localhost:8080/.json works, but trying http://localhost:8080/.infinity.json or http://localhost:8080/.1.json gives me an exception and error 500;

org.apache.sling.commons.json.JSONException: Misplaced endArray.
    org.apache.sling.commons.json.io.JSONWriter.end(JSONWriter.java:203)
org.apache.sling.commons.json.io.JSONWriter.endObject(JSONWriter.java:237) org.apache.sling.servlets.get.helpers.JsonResourceWriter.dump(JsonResourceWriter.java:128) org.apache.sling.servlets.get.helpers.JsonResourceWriter.dump(JsonResourceWriter.java:78) org.apache.sling.servlets.get.helpers.JsonRendererServlet.doGet(JsonRendererServlet.java:94) org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:262)

How do I fetch child nodes of the root node in json format? This is with sling current trunk from last week.

Reply via email to