Package org.json

Examples of org.json.JSONStringer.endObject()


    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try {
            stringer.object();
            this.toJSONString(stringer);
            stringer.endObject();
        } catch (JSONException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return stringer.toString();
View Full Code Here


            try {
                stringer.object();
                for (Entry<String, String> e : override.entrySet()) {
                    stringer.key(e.getKey().toUpperCase()).value(e.getValue());
                } // FOR
                stringer.endObject();
                this.fromJSON(new JSONObject(stringer.toString()), catalog_db);
            } catch (JSONException ex) {
                throw new IOException("Failed to load override parameters: " + override, ex);
            }
        }
View Full Code Here

            JSONStringer stringer = (JSONStringer)(new JSONStringer().object());
            int offset = 1;
            for (Integer partition : sorted) {
                stringer.key(partition.toString()).value(offset++);
            } // FOR
            out.write((stringer.endObject().toString() + "\n").getBytes());
           
            // Now Loop through each file individually so that we only have to load one into memory at a time
            for (Integer partition : sorted) {
                File in = markovs.get(partition);
                try {
View Full Code Here

                    markov.load(in, catalog_db);
                   
                    stringer = (JSONStringer)new JSONStringer().object();
                    stringer.key(partition.toString()).object();
                    markov.toJSON(stringer);
                    stringer.endObject().endObject();
                    out.write((stringer.toString() + "\n").getBytes());
                } catch (Exception ex) {
                    throw new Exception(String.format("Failed to copy MarkovGraphsContainer for partition %d from '%s'", partition, in), ex);
                }
            } // FOR
View Full Code Here

            JSONStringer stringer = (JSONStringer)(new JSONStringer().object());
            int offset = 1;
            for (Integer partition : sorted) {
                stringer.key(Integer.toString(partition)).value(offset++);
            } // FOR
            out.write((stringer.endObject().toString() + "\n").getBytes());
           
            // Now roll through each id and create a single JSONObject on each line
            for (Integer partition : sorted) {
                MarkovGraphsContainer markov = markovs.get(partition);
                assert(markov != null) : "Null MarkovGraphsContainer for partition #" + partition;
View Full Code Here

                graphs_ctr += markov.totalSize();
               
                stringer = (JSONStringer)new JSONStringer().object();
                stringer.key(partition.toString()).object();
                markov.toJSON(stringer);
                stringer.endObject().endObject();
                out.write((stringer.toString() + "\n").getBytes());
            } // FOR
            out.close();
        } catch (Exception ex) {
            LOG.error("Failed to serialize the " + className + " file '" + output_path + "'", ex);
View Full Code Here

    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try {
        stringer.object();
        toJSONString(stringer);
        stringer.endObject();
        } catch (JSONException e) {
            e.printStackTrace();
            return null;
        }
        return stringer.toString();
View Full Code Here

    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try {
            stringer.object();
            this.toJSONString(stringer);
            stringer.endObject();
        } catch (JSONException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return stringer.toString();
View Full Code Here

    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try {
            stringer.object();
            this.toJSONString(stringer);
            stringer.endObject();
        } catch (JSONException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return stringer.toString();
View Full Code Here

                .equals(param.getValue())) {
                stringer.key(param.getKey()).value(param.getValue());
            }
        }

        return stringer.endObject().toString();
    }

    public static Map<String, Object> parseJSON(String jsonBody) {
        final Map<String, Object> params = new HashMap<String, Object>();
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.