Package org.json.simple

Examples of org.json.simple.JSONObject.toJSONString()


                                                      "ID swap should have happened in launcher job [{0}]", action.getExternalId());
                }
                Counters counters = runningJob.getCounters();
                if (counters != null) {
                    JSONObject json = counterstoJson(counters);
                    context.setVar(HADOOP_COUNTERS, json.toJSONString());
                }
                else {

                    context.setVar(HADOOP_COUNTERS, "");
View Full Code Here


        JSONObject json = new JSONObject();
        json.put("query", query);
        json.put("suggestions", complete);

        if(callback != null && !callback.trim().isEmpty()) {
          print(callback.trim()+"("+json.toJSONString()+")");
        } else {
          print(json.toJSONString());
        }

    }
View Full Code Here

        json.put("suggestions", complete);

        if(callback != null && !callback.trim().isEmpty()) {
          print(callback.trim()+"("+json.toJSONString()+")");
        } else {
          print(json.toJSONString());
        }

    }

    private static final Logger LOG = Logger.getLogger(Autocomplete.class.getName());
View Full Code Here

                addResult(ja, result);
            }

            JSONObject jo = createResponse(q, searchTime, ja, matches, facets, didYouMean);
           
            print(jo.toJSONString());
            return;

        } catch (IndexEngineApiException e) {
            e.printStackTrace();
        }
View Full Code Here

        JSONObject msg = new JSONObject();
        msg.put("name", "test");
        msg.put("age", 11);
        msg.put("birthday", new Date().getTime());

        Event e = EventBuilder.withBody(msg.toJSONString().getBytes());
        channel.put(e);
        tx.commit();
        tx.close();

        sink.process();
View Full Code Here

        assertNull(arr.get(0));
        assertEquals(arr.get(1), "tmp");
        assertEquals(arr.get(2),10);
        assertEquals(arr.get(3),42.0);
        assertEquals(arr.get(4),false);
        String json = res.toJSONString();
        assertNotNull(json);
        JSONObject reparsed = (JSONObject) new JSONParser().parse(json);
        assertNotNull(reparsed);
        assertEquals(((List) reparsed.get("second")).get(1),"tmp");
    }
View Full Code Here

        JSONObject respond = new JSONObject();
        respond.put(Payload.TYPE.asKey(), type.toString().toLowerCase());
        if (agentDetails != null) {
            respond.putAll(agentDetails.toJSONObject());
        }
        byte[] ret = getBytes(respond.toJSONString());
        if (ret.length > MAX_MSG_SIZE) {
            throw new IllegalArgumentException("Message to send is larger (" + ret.length + " bytes) than maximum size of " + MAX_MSG_SIZE + " bytes.");
        }
        return ret;
    }
View Full Code Here

    @Test(expectedExceptions = IOException.class,expectedExceptionsMessageRegExp = ".*not.*parse.*")
    public void incomingWithLargerBuf() throws IOException {
        JSONObject data = new JSONObject();
        data.put("type", AbstractDiscoveryMessage.MessageType.QUERY.toString());
        String json = data.toJSONString();
        byte[] largeBuf = Arrays.copyOf(json.getBytes(),json.length() + 512);
        DiscoveryIncomingMessage in = new DiscoveryIncomingMessage(new DatagramPacket(largeBuf,largeBuf.length));

    }

View Full Code Here

    public DatagramPacket createDatagramPacket(Object ... vals) {
        JSONObject data = new JSONObject();
        for (int i = 0; i < vals.length; i+=2) {
            data.put(vals[i],vals[i+1]);
        }
        String json = data.toJSONString();
        return new DatagramPacket(json.getBytes(),json.getBytes().length);
    }


    private AgentDetails getAgentDetailsLargerThan(int size) {
View Full Code Here

                                                      "ID swap should have happened in launcher job [{0}]", action.getExternalId());
                }
                Counters counters = runningJob.getCounters();
                if (counters != null) {
                    JSONObject json = counterstoJson(counters);
                    context.setVar(HADOOP_COUNTERS, json.toJSONString());
                }
                else {

                    context.setVar(HADOOP_COUNTERS, "");
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.