List of usage examples for org.json.simple JSONObject toJSONString
public String toJSONString()
From source file:com.aerothai.database.user.UsersResource.java
/** * Retrieves representation of an instance of com.aerothai.UsersResource * @return an instance of java.lang.String *///from w w w . j av a 2 s .c o m @GET // Produces JSON as response @Produces("application/json") //@Produces("application/xml") public String listUser(@QueryParam("role") String role, @QueryParam("column") String column, @QueryParam("value") String value) { String response = null; String opt = null; UserService userService = new UserService(); System.out.println("List User All"); if (!userService.isNotNull(role)) { role = "0"; } if (userService.isNotNull(column) && userService.isNotNull(value)) { //System.out.println("column = :"+column+" v =:"+value); opt = column + " = '" + value + "'"; } try { JSONObject userData = null; userData = userService.GetUserAll(role, opt); response = userData.toJSONString(); } catch (Exception e) { System.out.println("error"); } return response; }
From source file:com.raphfrk.craftproxyclient.net.protocol.p172Play.P172PlayProtocol.java
@SuppressWarnings("unchecked") @Override/* w w w . j av a 2 s.c o m*/ public Packet getKick(String message) { JSONObject obj = new JSONObject(); obj.put("text", message); return new P17xKick(0x40, obj.toJSONString()); }
From source file:minor.commodity.CommodityQuote.java
@Override public String execute() { System.out.println("Ticker in Commodity Quote: " + getCticker()); System.out.println("Checking"); //List<CommodityDetails> sd2 = cdf.getCommodityData(getCticker()); //System.out.println("Size of return Value: "+sd2.size()); /*//from w w w .j a v a 2s. c o m for(CommodityDetails cd : sd2){ cdf.create(cd); }*/ JSONObject quote = commodityDetailsFacade.getCommodityData(getCticker()); System.out.println("Array List: " + quote.toJSONString()); //System.out.println("CDF String: "+cdf.toString()); //System.out.println("Checking again"); Set<String> st = quote.keySet(); try { for (String s : st) { if (quote.get(s) == null) { System.out.println("IN IF"); //quote.remove(s); quote.put(s, "NA"); } } } catch (Exception e) { System.out.println(e); } CommodityDetails cd = new CommodityDetails(quote); System.out.println(cd.getPERatio()); System.out.println(cd.getEBITDA()); System.out.println(cd.getPreviousClose()); System.out.println(cd.getDaysHigh()); System.out.println(cd.getVolume()); setSd(cd); //setSd(sd.add(cd)); if (true) { return "success"; } else { System.out.println("Checking again again"); return "error"; } }
From source file:com.aerothai.database.model.ModelResource.java
/** * Retrieves representation of an instance of com.aerothai.ModelResource * @return an instance of java.lang.String *//*from w w w .j av a 2 s . co m*/ @GET @Produces("application/json") public String listModelAt(@PathParam("id") int id) { String response = null; System.out.println("List Model At ID"); try { JSONObject modelData = null; ModelService modelService = new ModelService(); modelData = modelService.GetModelAt(id); response = modelData.toJSONString(); } catch (Exception e) { System.out.println("error"); } return response; }
From source file:com.fujitsu.dc.test.utils.UserDataUtils.java
/** * ??????.//from ww w . j ava2 s.c om * @param token * @param code ?? * @param cell * @param box * @return ? */ @SuppressWarnings("unchecked") public static TResponse create(String token, int code, String cell, String box) { JSONObject body = new JSONObject(); body.put("__id", "auth_test"); TResponse res = Http.request("box/odatacol/create.txt").with("cell", cell).with("box", box) .with("collection", "setodata").with("entityType", "Price") .with("accept", MediaType.APPLICATION_JSON).with("contentType", MediaType.APPLICATION_JSON) .with("token", "Bearer " + token).with("body", body.toJSONString()).returns().statusCode(code) .debug(); return res; }
From source file:de.hstsoft.sdeep.Configuration.java
@SuppressWarnings("unchecked") public void save() { JSONObject jsonObject = new JSONObject(); jsonObject.put(PREF_SAVEGAME_PATH, saveGamePath); jsonObject.put(PREF_AUTOREFRESH, autorefresh); try {/*from w ww.j a va 2s . c om*/ String jsonString = jsonObject.toJSONString(); FileWriter fileWriter = new FileWriter(configFile); fileWriter.append(jsonString); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:ch.simas.jtoggl.ProjectUser.java
public ProjectUser(String jsonString) { JSONObject object = (JSONObject) JSONValue.parse(jsonString); this.id = (Long) object.get("id"); this.hourly_rate = (Double) object.get("rate"); this.manager = (Boolean) object.get("manager"); JSONObject projectObject = (JSONObject) object.get("project"); if (projectObject != null) { this.project = new Project(projectObject.toJSONString()); }//from w w w . j a v a 2 s .c o m JSONObject userObject = (JSONObject) object.get("user"); if (userObject != null) { this.user = new User(userObject.toJSONString()); } }
From source file:com.aerothai.database.building.BuildingsResource.java
/** * Retrieves representation of an instance of com.aerothai.BuildingsResource * @return an instance of java.lang.String *///from w ww . j av a 2s. c om @GET // Produces JSON as response @Produces("application/json") //@Produces("application/xml") public String listBuilding() { String response = null; System.out.println("List Building All"); try { JSONObject buildingData = null; BuildingService buildingService = new BuildingService(); buildingData = buildingService.GetBuildingAll(); response = buildingData.toJSONString(); } catch (Exception e) { System.out.println("error"); } return response; }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.Sonar.java
@SuppressWarnings("unchecked") @Override/*from w w w . j ava 2s. c o m*/ public String toJSONString() { JSONObject o = new JSONObject(); o.put("type", ISensorProxy.SENSOR_NAME_SONAR); if (getTimestamp() != 0) { o.put("time", getTimestamp()); o.put("value", sonar); } return o.toJSONString(); }
From source file:com.aerothai.database.status.StatusResource.java
/** * Retrieves representation of an instance of com.aerothai.StatusResource * @return an instance of java.lang.String *//*from w w w. ja v a 2 s . c om*/ @GET @Produces("application/json") public String listStatusAt(@PathParam("id") int id) { String response = null; System.out.println("List Status At ID"); try { JSONObject statusData = null; StatusService statusService = new StatusService(); statusData = statusService.GetStatusAt(id); response = statusData.toJSONString(); } catch (Exception e) { System.out.println("error"); } return response; }