List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:MyCpuListener.java
@SuppressWarnings("unchecked") public void cpuEvent(CpuEvent event) { obj.put("timestamp", event.getEventTime()); JSONObject cpu = new JSONObject(); cpu.put("process", event.getProcessUse()); cpu.put("system", event.getSystemUse()); obj.put("cpu", cpu); IndexResponse response = eSC.getClient().prepareIndex(eSC.getIndex(), "cpu").setSource(obj.toJSONString()) .get();/*from w w w.j ava 2s. c om*/ }
From source file:com.imagelake.android.changephoneno.Servlet_ChangePhoneno.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { PrintWriter out = response.getWriter(); try {/*from www.ja va 2s. c o m*/ String type = request.getParameter("type"); if (type != null) { String uid = request.getParameter("uid"); if (type.equals("load_phone")) { if (uid != null) { User u = udi.getUser(Integer.parseInt(uid)); if (u != null) { JSONObject jo = new JSONObject(); jo.put("phn", u.getPhone()); System.out.println(jo.toJSONString()); out.write("json=" + jo.toJSONString()); } else { out.write("msg=Internal server error,Please try again later."); } } else { out.write("msg=Internal server error,Please try again later."); } } else if (type.equals("update_phone")) { String phn = request.getParameter("phn"); if (phn != null) { boolean k = udi.updatePhoneNo(Integer.parseInt(uid), phn); if (k) { out.write("msg=Successfully Completed."); } else { out.write("msg=Unable to complete the action,Please try again later."); } } else { out.write("msg=Internal server error,Please try again later."); } } } else { out.write("msg=Internal server error,Please try again later."); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.opensoc.json.serialization.JSONDecoderHelper.java
@SuppressWarnings("unchecked") public static JSONObject getJSON(DataInputStream data) throws IOException { // TODO Auto-generated method stub JSONObject output = new JSONObject(); int size = data.readInt(); for (int i = 0; i < size; i++) { String key = (String) getObject(data); Object value = getObject(data); output.put(key, value);//from w w w. ja va 2 s .c o m } return output; }
From source file:org.kitodo.data.index.elasticsearch.type.BatchType.java
@SuppressWarnings("unchecked") @Override/*from w w w. ja va2 s . c o m*/ public HttpEntity createDocument(Batch batch) { LinkedHashMap<String, String> orderedBatchMap = new LinkedHashMap<>(); orderedBatchMap.put("title", batch.getTitle()); String type = batch.getType() != null ? batch.getType().toString() : "null"; orderedBatchMap.put("type", type); JSONArray processes = new JSONArray(); List<Process> batchProcesses = batch.getProcesses(); for (Process process : batchProcesses) { JSONObject processObject = new JSONObject(); processObject.put("id", process.getId().toString()); processes.add(processObject); } JSONObject batchObject = new JSONObject(orderedBatchMap); batchObject.put("processes", processes); return new NStringEntity(batchObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:com.rackspacecloud.blueflood.outputs.serializers.BatchedMetricsJSONOutputSerializer.java
@Override public JSONObject transformRollupData(Map<Locator, MetricData> metricData, Set<MetricStat> filterStats) throws SerializationException { final JSONObject globalJSON = new JSONObject(); final JSONArray metricsArray = new JSONArray(); for (Map.Entry<Locator, MetricData> one : metricData.entrySet()) { final JSONObject singleMetricJSON = new JSONObject(); singleMetricJSON.put("metric", one.getKey().getMetricName()); singleMetricJSON.put("unit", one.getValue().getUnit() == null ? Util.UNKNOWN : one.getValue().getUnit()); singleMetricJSON.put("type", one.getValue().getType()); Set<MetricStat> oneFilterStats = fixFilterStats(one.getValue(), filterStats); JSONArray values = transformDataToJSONArray(one.getValue(), oneFilterStats); singleMetricJSON.put("data", values); metricsArray.add(singleMetricJSON); }//ww w. ja v a2 s.c om globalJSON.put("metrics", metricsArray); return globalJSON; }
From source file:es.tid.keyserver.https.protocol.ResponseJSON.java
/** * Constructor with data from JSON "output data" field as input parameter. * @param type Specified the JSON Output type (OUTPUT / ERROR). * @param data This field contains the data associated with JSON "output data" field. *///from w w w . jav a 2 s . c o m public ResponseJSON(String type, String data) { outputData = new JSONObject(); setOutputData(type, data); }
From source file:com.au.splashinc.JControl.Load.JsonLoader.java
protected JSONObject GetJSONObject(Object key, Object value) { JSONObject jo = new JSONObject(); jo.put(key, value); return jo; }
From source file:com.opensoc.json.serialization.JSONEncoderHelper.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static JSONObject getJSON(Configuration config) { JSONObject output = new JSONObject(); if (!config.isEmpty()) { Iterator it = config.getKeys(); while (it.hasNext()) { String k = (String) it.next(); // noinspection unchecked String v = (String) config.getProperty(k); output.put(k, v);/*from w ww. j a va2s. c o m*/ } } return output; }
From source file:com.github.sourjson.translat.def.ClassTranslater.java
@SuppressWarnings("unchecked") @Override/* ww w .jav a 2 s.co m*/ public @CheckForNull JSONObject serialize(Class obj, Type typeOnServer, AnnotatedElement el, @CheckForNull Object enclosing, SourJson json, double version) { JSONObject ret = new JSONObject(); ret.put("name", obj.getName()); return ret; }
From source file:com.shazam.dataengineering.pipelinebuilder.DeploymentLog.java
public DeploymentLog() { log = new JSONObject(); log.put(ROOT, new JSONArray()); }