Example usage for org.json.simple JSONObject put

List of usage examples for org.json.simple JSONObject put

Introduction

In this page you can find the example usage for org.json.simple JSONObject put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:ab.server.proxy.message.ProxyMouseWheelMessage.java

@SuppressWarnings("unchecked")
@Override// www . java2 s.  co  m
public JSONObject getJSON() {
    JSONObject o = new JSONObject();
    o.put("delta", delta);
    return o;
}

From source file:mml.handler.scratch.ScratchLayer.java

public JSONObject toJSONObject() {
    JSONObject jObj = new JSONObject();
    jObj.put(JSONKeys.NAME, name);
    jObj.put(JSONKeys.BODY, mml);//ww  w .ja va 2 s .  c o m
    return jObj;
}

From source file:com.twitter.hdfsdu.data.NodeData.java

public JSONObject toJSON() {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("path", this.path);
    jsonObject.put("fileSize", fileSize);
    jsonObject.put("nChildren", nChildren);
    jsonObject.put("leaf", leaf);
    return jsonObject;
}

From source file:clientpaxos.ClientPaxos.java

public static void getClientAddress() throws Exception {
    String json;/*from  ww w. j ava  2 s  . c o  m*/
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("method", "client_address");
    json = jsonObject.toString();
    System.out.println("Send to server : " + json);
    sendToServer(json);
}

From source file:ab.server.proxy.message.ProxyDragMessage.java

@SuppressWarnings("unchecked")
@Override/*from  ww  w . jav  a2  s .  c  om*/
public JSONObject getJSON() {
    JSONObject o = new JSONObject();
    o.put("x", x);
    o.put("y", y);
    o.put("dx", dx);
    o.put("dy", dy);
    return o;
}

From source file:org.kitodo.data.elasticsearch.index.type.DocketType.java

@SuppressWarnings("unchecked")
@Override//from   w  w w . ja  v  a 2s.  c  om
public HttpEntity createDocument(Docket docket) {

    JSONObject docketObject = new JSONObject();
    docketObject.put("title", docket.getTitle());
    docketObject.put("file", docket.getFile());

    return new NStringEntity(docketObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.cloudera.lib.wsrs.TestJSONProvider.java

@Test
@SuppressWarnings("unchecked")
public void test() throws Exception {
    JSONProvider p = new JSONProvider();
    Assert.assertTrue(p.isWriteable(JSONObject.class, null, null, null));
    Assert.assertFalse(p.isWriteable(XTest.class, null, null, null));
    Assert.assertEquals(p.getSize(null, null, null, null, null), -1);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JSONObject json = new JSONObject();
    json.put("a", "A");
    p.writeTo(json, JSONObject.class, null, null, null, null, baos);
    baos.close();//from  w  w  w. j  a  va 2s.  c  om
    Assert.assertEquals(new String(baos.toByteArray()).trim(), "{\"a\":\"A\"}");
}

From source file:com.cloudera.lib.wsrs.TestJSONMapProvider.java

@Test
@SuppressWarnings("unchecked")
public void test() throws Exception {
    JSONMapProvider p = new JSONMapProvider();
    Assert.assertTrue(p.isWriteable(Map.class, null, null, null));
    Assert.assertFalse(p.isWriteable(XTest.class, null, null, null));
    Assert.assertEquals(p.getSize(null, null, null, null, null), -1);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JSONObject json = new JSONObject();
    json.put("a", "A");
    p.writeTo(json, JSONObject.class, null, null, null, null, baos);
    baos.close();/*w  w w .  j  av  a 2s .  c  o  m*/
    Assert.assertEquals(new String(baos.toByteArray()).trim(), "{\"a\":\"A\"}");
}

From source file:com.oic.event.map.GetMapList.java

@Override
public void ActionEvent(JSONObject json, WebSocketListener webSocket) {
    JSONObject responseJSON = new JSONObject();
    responseJSON.put("method", "getmaplist");
    MapFactory mapFactory = MapFactory.getInstance();
    Map<Integer, String> maps = new HashMap<>();
    for (OicMap map : mapFactory.getMapList()) {
        maps.put(map.getMapId(), map.getMapName());
    }/*from w w w . ja  v  a 2 s  . com*/
    responseJSON.put("maplist", maps);
    webSocket.sendJson(responseJSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.BatchType.java

@SuppressWarnings("unchecked")
@Override//from w w  w  .  ja v  a  2 s  . c o m
public HttpEntity createDocument(Batch batch) {

    JSONObject batchObject = new JSONObject();
    batchObject.put("title", batch.getTitle());
    String type = batch.getType() != null ? batch.getType().toString() : null;
    batchObject.put("type", type);
    batchObject.put("processes", addObjectRelation(batch.getProcesses()));

    return new NStringEntity(batchObject.toJSONString(), ContentType.APPLICATION_JSON);
}