Package org.apache.sling.commons.json.io

Examples of org.apache.sling.commons.json.io.JSONWriter.object()


        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        try {
            final JSONWriter w = new JSONWriter(response.getWriter());
            w.setTidy(true);
            w.object();
            for(Map.Entry<String, AtomicInteger> entry : counters.entrySet()) {
                w.key(entry.getKey()).value(entry.getValue());
            }
            w.endObject();
        } catch(JSONException je) {
View Full Code Here


        public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
            if (type == InputStream.class) {
                StringWriter buffer = new StringWriter();
                try {
                    JSONWriter writer = new JSONWriter(buffer);
                    writer.object();
                    writer.key("options");
                    writer.array();
                    for (Item item : list.getItems()) {
                        writer.object();
                        writer.key("text").value(item.getTitle());
View Full Code Here

                    JSONWriter writer = new JSONWriter(buffer);
                    writer.object();
                    writer.key("options");
                    writer.array();
                    for (Item item : list.getItems()) {
                        writer.object();
                        writer.key("text").value(item.getTitle());
                        writer.key("value").value(item.getValue());
                        writer.endObject();
                    }
                    writer.endArray();
View Full Code Here

        if (request.getRequestPathInfo().getExtension().equals("json")) {
            response.setContentType("application/json");
            JSONWriter writer = new JSONWriter(response.getWriter());
            try {
                writer.object();
                for (final FlushResult result : overallResults) {
                    writer.key(result.agentId);
                    writer.value(result.success);
                }
                writer.endObject();
View Full Code Here

            // iterate through the result set and build the "json result"
            while (result.hasNext() && count != 0) {
                Map<String, Object> row = result.next();

                w.object();
                String path = row.get("jcr:path").toString();

                w.key("name");
                w.value(ResourceUtil.getName(path));
View Full Code Here

        final Writer out = response.getWriter();
        final JSONWriter w = new JSONWriter(out);

        try {
            w.object();
            for (Map.Entry<String, String> e : data.entrySet()) {
                w.key(e.getKey());
                w.value(e.getValue());
            }
            w.endObject();
View Full Code Here

    /** Dump given property in JSON */
    public void dump(Property p, Writer w) throws JSONException,
            ValueFormatException, RepositoryException {
        final JSONWriter jw = new JSONWriter(w);
        jw.object();
        writeProperty(jw, p);
        jw.endObject();
    }

    /** Dump given node in JSON, optionally recursing into its child nodes */
 
View Full Code Here

                            }
                        }
                    }

                    for (String cat : categories) {
                        writer.object();
                        writer.key("value");
                        writer.value(cat);
                        writer.key("text");
                        writer.value(cat);
                        writer.endObject();
View Full Code Here

    /** Dump given property in JSON */
    public void dump(Property p, Writer w) throws JSONException,
            ValueFormatException, RepositoryException {
        final JSONWriter jw = new JSONWriter(w);
        jw.object();
        writeProperty(jw, p);
        jw.endObject();
    }

    /** Dump given node in JSON, optionally recursing into its child nodes */
 
View Full Code Here

            // iterate through the result set and build the "json result"
            while (result.hasNext() && count != 0) {
                Map<String, Object> row = result.next();

                w.object();
                String path = row.get("jcr:path").toString();

                w.key("name");
                w.value(ResourceUtil.getName(path));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.