Package org.apache.sling.commons.json.jcr

Examples of org.apache.sling.commons.json.jcr.JsonItemWriter


        // compute currentNode values in JSON format
        final StringWriter jsonData = new StringWriter();
        if(n != null) {
            final PrintWriter pw = new PrintWriter(jsonData);
            final JsonItemWriter j = new JsonItemWriter(null);
            final int maxRecursionLevels = 1;
            pw.print("var currentNode=");
            j.dump(n, pw, maxRecursionLevels);
            pw.print(";");
            pw.flush();
        }

        // run XSLT transform on script, passing parameter
View Full Code Here


    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());
View Full Code Here

    /** Recursion level selector that means "all levels" */
    public static final String INFINITY = "infinity";

    public JsonRendererServlet() {
        itemWriter = new JsonItemWriter(null);
    }
View Full Code Here

    /** Render a Property by dumping its String value */
    private void renderProperty(Property p, SlingHttpServletResponse resp)
            throws JSONException, RepositoryException, IOException {
        resp.setContentType(responseContentType);
        resp.setCharacterEncoding("UTF-8");
        new JsonItemWriter(null).dump(p, resp.getWriter());
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.json.jcr.JsonItemWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.