List of usage examples for org.json.simple JSONObject put
V put(K key, V value);
From source file:com.oic.event.PosUpdate.java
@Override public void ActionEvent(JSONObject json, WebSocketListener webSocket) { JSONObject responseJSON = new JSONObject(); responseJSON.put("method", "posupdate"); responseJSON.put("status", 0); if (validate(json)) { MapFactory mapFactory = MapFactory.getInstance(); OicMap map = mapFactory.getMap(Integer.parseInt(json.get("mapid").toString())); map.BroadCastMap(responseJSON);//from w w w.j av a 2 s . c o m } else { OicCharacter c = webSocket.getCharacter(); c.getMap().BroadCastMap(responseJSON); } }
From source file:org.kitodo.data.elasticsearch.index.type.HistoryType.java
@SuppressWarnings("unchecked") @Override/* w w w.j a v a2 s . co m*/ public HttpEntity createDocument(History history) { JSONObject historyObject = new JSONObject(); historyObject.put("numericValue", history.getNumericValue()); historyObject.put("stringValue", history.getStringValue()); historyObject.put("type", history.getHistoryType().getValue()); String date = history.getDate() != null ? formatDate(history.getDate()) : null; historyObject.put("date", date); Integer process = history.getProcess() != null ? history.getProcess().getId() : null; historyObject.put("process", process); return new NStringEntity(historyObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:com.mobicage.rogerthat.form.UnicodeWidgetResult.java
@SuppressWarnings("unchecked") @Override/*from w ww .j a va2s .co m*/ public JSONObject toJSONObject() { JSONObject obj = new JSONObject(); obj.put("value", value); return obj; }
From source file:com.nubits.nubot.tests.TestAggregateOptions.java
private void aggregate() { Map setMap = new HashMap(); for (int i = 0; i < fileNames.size(); i++) { try {// ww w . j a va 2 s .c om JSONParser parser = new JSONParser(); JSONObject fileJSON = (JSONObject) (parser.parse(FileSystem.readFromFile(fileNames.get(i)))); JSONObject tempOptions = (JSONObject) fileJSON.get("options"); Set tempSet = tempOptions.entrySet(); for (Object o : tempSet) { Entry entry = (Entry) o; setMap.put(entry.getKey(), entry.getValue()); } } catch (ParseException ex) { LOG.severe("Parse exception \n" + ex.toString()); System.exit(0); } } JSONObject optionsObject = new JSONObject(); optionsObject.put("options", setMap); }
From source file:MyGCListener.java
@SuppressWarnings("unchecked") public void gcEvent(GCEvent event) { //System.out.println("I've been called in myGCListener"); obj.put("timestamp", event.getEventTime()); JSONObject gc = new JSONObject(); gc.put("type", event.getType()); gc.put("size", event.getHeapSize()); gc.put("used", event.getUsedHeapAfterGC()); gc.put("duration", event.getPauseTime()); obj.put("gc", gc); IndexResponse response = eSC.getClient().prepareIndex(eSC.getIndex(), "gc").setSource(obj.toJSONString()) .get();//from w w w.java 2 s.co m }
From source file:com.gti.redirects.Redirects.Redirect.java
public JSONObject toJsonObject() { JSONObject redirect = new JSONObject(); redirect.put("domain", domain); redirect.put("type", type); redirect.put("redirect_to", redirect_to); return redirect; }
From source file:di.uniba.it.tee2.api.v1.GetDocument.java
@GET public Response search(@PathParam("docid") String docid) { try {//from w ww. ja va 2 s .co m SearchServiceWrapper instance = SearchServiceWrapper.getInstance( ServerConfig.getInstance().getProperty("search.language"), ServerConfig.getInstance().getProperty("search.index")); Document document = instance.getSearch().getDocument(docid); JSONObject json = new JSONObject(); json.put("id", document.get("id")); json.put("title", document.get("title")); json.put("content", document.get("content")); return Response.ok(json.toString()).build(); } catch (Exception ex) { Logger.getLogger(GetDocument.class.getName()).log(Level.SEVERE, null, ex); return Response.serverError().build(); } }
From source file:naftoreiclag.villagefive.InvItem.java
@Override public String toJSONString() { JSONObject object = new JSONObject(); object.put("classId", "itemEntity"); object.put("entityData", entity); return null;//from w w w. j a va 2 s. c om }
From source file:backend.FriendRequest.java
@Override public JSONObject jsonize() { JSONObject o = new JSONObject(); o.put("sender", m_sender.get_user_id()); o.put("sender_alias", m_sender.get_alias()); o.put("receiver", m_receiver.get_user_id()); o.put("receiver_alias", m_receiver.get_alias()); return o;/* w ww . j a v a 2 s .com*/ }
From source file:com.cloudera.hoop.fs.FSSetReplication.java
/** * Executes the filesystem operation.// www. j a v a 2 s . com * * @param fs filesystem instance to use. * @return <code>true</code> if the replication value was set, * <code>false</code> otherwise. * @throws IOException thrown if an IO error occured. */ @Override @SuppressWarnings("unchecked") public JSONObject execute(FileSystem fs) throws IOException { boolean ret = fs.setReplication(path, replication); JSONObject json = new JSONObject(); json.put("setReplication", ret); return json; }