Package org.json

Examples of org.json.JSONWriter


       
        return new ReconStats(nonBlanks, newTopics, matchedTopics);
    }
   
    public void save(Writer writer) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try {
            write(jsonWriter, new Properties());
        } catch (JSONException e) {
            e.printStackTrace();
        }
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

    abstract public List<Recon> batchRecon(List<ReconJob> jobs, long historyEntryID);
   
    abstract public Recon createNewRecon(long historyEntryID);
   
    public void save(Writer writer) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try {
            write(jsonWriter, new Properties());
        } catch (JSONException e) {
            e.printStackTrace();
        }
View Full Code Here

    static public void respond(HttpServletResponse response, String status, String message)
        throws IOException {
   
        Writer w = response.getWriter();
        try {
            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();
        } catch (JSONException e) {
            // This can never occue
        }
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

               
        try {
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Type", "application/json");
           
            JSONWriter writer = new JSONWriter(response.getWriter());
           
            writer.object();
           
            for (String key : ps.getKeys()) {
                Object pref = ps.get(key);
                if (pref == null || pref instanceof String || pref instanceof Number || pref instanceof Boolean) {
                    writer.key(key);
                    writer.value(pref);
                }
            }
           
            writer.endObject();
        } catch (JSONException e) {
            respondException(response, e);
        }
    }
View Full Code Here

            if (historyEntry != null) {
                /*
                 * If the operation has been done, return the new cell's data
                 * so the client side can update the cell's rendering right away.
                 */
                JSONWriter writer = new JSONWriter(response.getWriter());

                Pool pool = new Pool();
                Properties options = new Properties();
                options.put("pool", pool);

                writer.object();
                writer.key("code"); writer.value("ok");
                writer.key("historyEntry"); historyEntry.write(writer, options);
                writer.key("cell"); process.newCell.write(writer, options);
                writer.key("pool"); pool.write(writer, options);
                writer.endObject();
            } else {
                respond(response, "{ \"code\" : \"pending\" }");
            }
        } catch (Exception e) {
            respondException(response, e);
View Full Code Here

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

            Project project = getProject(request);
            //Engine engine = getEngine(request, project);
           
            JSONWriter writer = new JSONWriter(response.getWriter());

            writer.array();
            for (Column column : project.columnModel.columns) {
                writer.object();
                    write(project, column, writer);
                writer.endObject();
            }
            writer.endArray();
           
            //Refine.log("Obtained columns info in " + (System.currentTimeMillis() - start) + "ms");
        } catch (Exception e) {
            e.printStackTrace();
            respondException(response, e);
View Full Code Here

        try {
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Type", "application/json");
           
            Properties options = new Properties();
            JSONWriter writer = new JSONWriter(response.getWriter());
           
            writer.object();
            writer.key("columnModel"); project.columnModel.write(writer, options);
            writer.key("recordModel"); project.recordModel.write(writer, options);
           
            writer.key("overlayModels"); writer.object();
            for (String modelName : project.overlayModels.keySet()) {
                OverlayModel overlayModel = project.overlayModels.get(modelName);
                if (overlayModel != null) {
                    writer.key(modelName);
                   
                    project.overlayModels.get(modelName).write(writer, options);
                }
            }
            writer.endObject();
           
            writer.key("scripting"); writer.object();
            for (String languagePrefix : MetaParser.getLanguagePrefixes()) {
                LanguageInfo info = MetaParser.getLanguageInfo(languagePrefix);
               
                writer.key(languagePrefix);
                writer.object();
                    writer.key("name"); writer.value(info.name);
                    writer.key("defaultExpression"); writer.value(info.defaultExpression);
                writer.endObject();
            }
            writer.endObject();
           
            writer.endObject();
        } catch (JSONException e) {
            HttpUtilities.respondException(response, e);
        }
    }
View Full Code Here

        writer.write(key + "="); writer.write(Integer.toString(recons.size())); writer.write('\n');
        for (Recon recon : recons.values()) {
            Pool pool = (Pool) options.get("pool");
            pool.poolReconCandidates(recon);

            JSONWriter jsonWriter = new JSONWriter(writer);
            try {
                recon.write(jsonWriter, options);
            } 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.