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

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


            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) {
            throw (IOException)new IOException("JSONException in doGet").initCause(je);
        }
    }
}
View Full Code Here


                    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();
                    writer.endObject();
                    return (AdapterType) new ByteArrayInputStream(buffer.toString().getBytes("UTF-8"));
                } catch (Exception e) {
View Full Code Here

                        writer.key("text").value(item.getTitle());
                        writer.key("value").value(item.getValue());
                        writer.endObject();
                    }
                    writer.endArray();
                    writer.endObject();
                    return (AdapterType) new ByteArrayInputStream(buffer.toString().getBytes("UTF-8"));
                } catch (Exception e) {
                    log.warn("Unable to generate JSON object.", e);
                    return null;
                }
View Full Code Here

                writer.object();
                for (final FlushResult result : overallResults) {
                    writer.key(result.agentId);
                    writer.value(result.success);
                }
                writer.endObject();
            } catch (JSONException e) {
                throw new ServletException("Unable to output JSON data", e);
            }
        } else {
            String suffix;
View Full Code Here

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

        } catch (JSONException jse) {
            out.write(jse.toString());

        } finally {
View Full Code Here

                if (!properties.isEmpty()) {
                    Resource nodeRes = resolver.getResource(path);
                    dumpProperties(w, nodeRes, properties);
                }

                w.endObject();
                count--;
            }
            w.endArray();
        } catch (JSONException je) {
            throw wrapException(je);
View Full Code Here

    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 */
    protected void dump(Node node, JSONWriter w, int currentRecursionLevel,
            int maxRecursionLevels) throws RepositoryException, JSONException {
View Full Code Here

                        writer.object();
                        writer.key("value");
                        writer.value(cat);
                        writer.key("text");
                        writer.value(cat);
                        writer.endObject();
                    }

                } catch (IllegalArgumentException e) {
                    // no matching type. no need to log, just return empty array.
                }
View Full Code Here

    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 */
    protected void dump(Node node, JSONWriter w, int currentRecursionLevel,
            int maxRecursionLevels) throws RepositoryException, JSONException {
View Full Code Here

                if (!properties.isEmpty()) {
                    Resource nodeRes = resolver.getResource(path);
                    dumpProperties(w, nodeRes, properties);
                }

                w.endObject();
                count--;
            }
            w.endArray();
        } catch (JSONException je) {
            throw wrapException(je);
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.