Package org.json

Examples of org.json.JSONWriter


        response.setHeader("Content-Type", "application/json");

        HistoryEntry historyEntry = project.processManager.queueProcess(process);
        if (historyEntry != null) {
            Writer w = response.getWriter();
            JSONWriter writer = new JSONWriter(w);
            Properties options = new Properties();

            writer.object();
            writer.key("code"); writer.value("ok");
            writer.key("historyEntry"); historyEntry.write(writer, options);
            writer.endObject();

            w.flush();
            w.close();
        } else {
            respond(response, "{ \"code\" : \"pending\" }");
View Full Code Here


    static protected void respond(HttpServletResponse response, String status, String message)
        throws IOException, JSONException {

        Writer w = response.getWriter();
        JSONWriter writer = new JSONWriter(w);
        writer.object();
        writer.key("status"); writer.value(status);
        writer.key("message"); writer.value(message);
        writer.endObject();
        w.flush();
        w.close();
    }
View Full Code Here

        response.setCharacterEncoding("UTF-8");
        response.setHeader("Content-Type", "application/json");

        Writer w = response.getWriter();
        JSONWriter writer = new JSONWriter(w);

        o.write(writer, options);
        w.flush();
        w.close();
    }
View Full Code Here

        }
    }

    @Override
    public void save(HistoryEntry historyEntry, Writer writer, Properties options) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try {
            historyEntry.write(jsonWriter, options);
        } catch (JSONException e) {
            e.printStackTrace();
        }
View Full Code Here

       
        Collection<Recon> recons2 = recons.values();
        writer.write("reconCount=" + recons2.size()); writer.write('\n');
       
        for (Recon recon : recons2) {
            JSONWriter jsonWriter = new JSONWriter(writer);
            try {
                recon.write(jsonWriter, options);
               
                writer.write('\n');
            } catch (JSONException e) {
View Full Code Here

       
        writer.endObject();
    }
   
    public void save(Writer writer, Properties options) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try {
            write(jsonWriter, options);
        } catch (JSONException e) {
            e.printStackTrace();
        }
View Full Code Here

            List<Exception> exceptions = new LinkedList<Exception>();
           
            ImportingUtilities.previewParse(job, format, optionObj, exceptions);
           
            Writer w = response.getWriter();
            JSONWriter writer = new JSONWriter(w);
            try {
                writer.object();
                if (exceptions.size() == 0) {
                    job.project.update(); // update all internal models, indexes, caches, etc.
                   
                    writer.key("status"); writer.value("ok");
                } else {
                    writer.key("status"); writer.value("error");
                    writer.key("errors");
                    writer.array();
                    writeErrors(writer, exceptions);
                    writer.endArray();
                }
                writer.endObject();
            } catch (JSONException e) {
                throw new ServletException(e);
            } finally {
                w.flush();
                w.close();
View Full Code Here

    private void replyWithJobData(HttpServletRequest request, HttpServletResponse response, ImportingJob job)
        throws ServletException, IOException {
       
        Writer w = response.getWriter();
        JSONWriter writer = new JSONWriter(w);
        try {
            writer.object();
            writer.key("code"); writer.value("ok");
            writer.key("job"); job.write(writer, new Properties());
            writer.endObject();
        } catch (JSONException e) {
            throw new ServletException(e);
        } finally {
            w.flush();
            w.close();
View Full Code Here

        }
        _precomputes.put(key, value);
    }
   
    public void save(Writer writer) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try {
            write(jsonWriter, new Properties());
        } catch (JSONException e) {
            e.printStackTrace();
        }
View Full Code Here

        return (g.startColumnIndex >= startColumnIndex &&
            g.startColumnIndex < startColumnIndex + columnSpan);
    }
   
    public void save(Writer writer) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try {
            write(jsonWriter, new Properties());
        } catch (JSONException e) {
            e.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of org.json.JSONWriter

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.