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

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


                    for (String cat : categories) {
                        writer.object();
                        writer.key("value");
                        writer.value(cat);
                        writer.key("text");
                        writer.value(cat);
                        writer.endObject();
                    }

                } catch (IllegalArgumentException e) {
View Full Code Here


                Map<String, Object> row = result.next();

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

                w.key("name");
                w.value(ResourceUtil.getName(path));

                // dump columns
                for (String colName : row.keySet()) {
                    w.key(colName);
View Full Code Here

                w.key("name");
                w.value(ResourceUtil.getName(path));

                // dump columns
                for (String colName : row.keySet()) {
                    w.key(colName);
                    String strValue = "";
                    if (colName.equals(REP_EXCERPT)) {
                        Object ev = row.get("rep:excerpt(" + exerptPath + ")");
                        strValue = (ev == null) ? "" : ev.toString();
                    } else {
View Full Code Here

        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();

        } catch (JSONException jse) {
View Full Code Here

        response.setCharacterEncoding("utf-8");
        try {
            JSONWriter w = new JSONWriter(response.getWriter());
            w.setTidy(true);
            w.object();
            w.key("tasks").array();
            for (RcpTask task: taskMgr.getTasks().values()) {
                task.write(w);
            }
            w.endArray();
            w.endObject();
View Full Code Here

            response.setContentType("application/json");
            response.setCharacterEncoding("utf-8");
            JSONWriter w = new JSONWriter(response.getWriter());
            w.setTidy(true);
            w.object();
            w.key("status").value("ok");
            if (task != null) {
                w.key("id").value(task.getId());
            }
            w.endObject();
View Full Code Here

            JSONWriter w = new JSONWriter(response.getWriter());
            w.setTidy(true);
            w.object();
            w.key("status").value("ok");
            if (task != null) {
                w.key("id").value(task.getId());
            }
            w.endObject();

        } catch (Exception e) {
            log.error("Error while executing command {}", cmd, e);
View Full Code Here

            response.setStatus(500);
            JSONWriter w = new JSONWriter(response.getWriter());
            w.setTidy(true);
            try {
                w.object();
                w.key("status").value("error");
                w.key("message").value("Error while executing '" + cmd + "': " + e.getMessage());
                w.endObject();
            } catch (JSONException e1) {
                // ignore
            }
View Full Code Here

            JSONWriter w = new JSONWriter(response.getWriter());
            w.setTidy(true);
            try {
                w.object();
                w.key("status").value("error");
                w.key("message").value("Error while executing '" + cmd + "': " + e.getMessage());
                w.endObject();
            } catch (JSONException e1) {
                // ignore
            }
        }
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.