List of usage examples for org.json.simple JSONObject toJSONString
public String toJSONString()
From source file:de.instanttouch.messaging.protocol.translators.SnakeJsonMessageFormat.java
private SnakeRawMessage readMessage(SnakeJSONReader reader) throws IOException { SnakeRawMessage rawMessage = new SnakeRawMessage(); JSONObject jsonObject = (JSONObject) reader.parse(); JSONObject header = (JSONObject) jsonObject.get(SnakeMessage.HEADER); try {/*w ww .j a v a 2 s .c o m*/ reader.readEntity(rawMessage.header(), header); } catch (Exception e) { throw new SnakeMessagingException(e); } JSONObject payload = (JSONObject) jsonObject.get(SnakeMessage.PAYLOAD); String payLoadStr = payload.toJSONString(); rawMessage.setData(payLoadStr.getBytes()); return rawMessage; }
From source file:naftoreiclag.villagefive.Inventory.java
public String toJSONString() { JSONObject object = new JSONObject(); for (Map.Entry<Integer, InvItem> entry : items.entrySet()) { object.put(entry.getKey(), entry.getValue()); }/* ww w .ja v a 2 s . c om*/ return object.toJSONString(); }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.Speed.java
@SuppressWarnings("unchecked") @Override// www .ja va2 s.c o m public String toJSONString() { JSONObject o = new JSONObject(); o.put("type", "speed"); if (getTimestamp() != 0) { o.put("time", getTimestamp()); o.put("value", speedOverGround); } return o.toJSONString(); }
From source file:com.aerothai.database.role.RoleResource.java
/** * Retrieves representation of an instance of com.aerothai.RoleResource * @return an instance of java.lang.String */// w w w . j a v a 2s . c o m @GET @Produces("application/json") public String listRoleAt(@PathParam("id") int id) { String response = null; System.out.println("List Role At ID"); try { JSONObject roleData = null; RoleService roleService = new RoleService(); roleData = roleService.GetRoleAt(id); response = roleData.toJSONString(); } catch (Exception e) { System.out.println("error"); } return response; }
From source file:com.aerothai.database.dept.DeptResource.java
/** * Retrieves representation of an instance of com.aerothai.DeptResource * @return an instance of java.lang.String */// w w w .jav a 2s.com @GET @Produces("application/json") public String listDeptAt(@PathParam("id") int id) { String response = null; System.out.println("List Dept At ID"); try { JSONObject deptData = null; DeptService deptService = new DeptService(); deptData = deptService.GetDeptAt(id); response = deptData.toJSONString(); } catch (Exception e) { System.out.println("error"); } return response; }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.Course.java
@SuppressWarnings("unchecked") @Override//from w ww . j av a2 s .c om public String toJSONString() { JSONObject o = new JSONObject(); o.put("type", "course"); if (getTimestamp() != 0) { o.put("time", getTimestamp()); o.put("value", courseOverGround); } return o.toJSONString(); }
From source file:com.aerothai.database.unit.UnitResource.java
/** * Retrieves representation of an instance of com.aerothai.UnitResource * @return an instance of java.lang.String *///from w w w .j av a 2 s. c om @GET @Produces("application/json") public String listUnitAt(@PathParam("id") int id) { String response = null; System.out.println("List Unit At ID"); try { JSONObject unitData = null; UnitService unitService = new UnitService(); unitData = unitService.GetUnitAt(id); response = unitData.toJSONString(); } catch (Exception e) { System.out.println("error"); } return response; }
From source file:com.imagelake.earnings.Servlet_EarningsValues.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { PrintWriter out = response.getWriter(); try {/*from w ww. ja va 2 s .c o m*/ String uid = request.getParameter("uid"); if (uid != null && !uid.equals("")) { uidd = Integer.parseInt(uid); PaymentPreferences pp = ppimp.getPendingEarning(uidd, 1); double pd = 00.00; double ad = 00.00; if (pp != null) { pd = pp.getAmount(); DecimalFormat df1 = new DecimalFormat("#.##"); pd = Double.valueOf(df1.format(pd)); } SellerIncome sin = sidi.getSellerIncome(uidd); ad = sin.getTotal(); DecimalFormat df = new DecimalFormat("#.##"); ad = Double.valueOf(df.format(ad)); double netamo = ad - pd; DecimalFormat df2 = new DecimalFormat("#.##"); netamo = Double.valueOf(df2.format(netamo)); JSONObject jo = new JSONObject(); jo.put("pe", pd); jo.put("ab", ad); jo.put("ne", netamo); out.write("json=" + jo.toJSONString()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:io.personium.client.MetadataLinkManager.java
/** * This method is used to create the link. * @param cx Target object to create link * @throws DaoException Exception thrown */// w w w . j a v a2 s .c om @SuppressWarnings("unchecked") public void link(AbstractODataContext cx) throws DaoException { String uri = getLinkUrl(cx); JSONObject body = new JSONObject(); body.put("uri", cx.getODataLink()); IRestAdapter rest = RestAdapterFactory.create(accessor); rest.post(uri, body.toJSONString(), RestAdapter.CONTENT_TYPE_JSON); }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.Altitude.java
@SuppressWarnings("unchecked") @Override//from ww w . j av a 2 s.c om public String toJSONString() { JSONObject o = new JSONObject(); o.put("type", "altitude"); if (getTimestamp() != 0) { o.put("time", getTimestamp()); o.put("value", altitudeOverGround); } return o.toJSONString(); }