List of usage examples for org.json.simple JSONObject toJSONString
public String toJSONString()
From source file:io.personium.test.jersey.box.odatacol.schema.complextypeproperty.ComplexTypePropertyUtils.java
/** * ComplexTypeProperty?.// www . j a v a 2s.com * @param cell ?? * @param box ?? * @param collection ?? * @param srcComplexTypePropertyName ?ComplexTypeProperty?? * @param srcComplexTypeName ?ComplexType?? * @param complexTypePropertyName ??ComplexTypeProperty?? * @param complexTypeName ??ComplexType?? * @param type Property?Type * @param nullable Property?Nullable * @param defaultValue Property?DefaultValue * @param collectionKind Property?collectionKind * @return ? */ @SuppressWarnings("unchecked") public static PersoniumResponse create(String cell, String box, String collection, String srcComplexTypePropertyName, String srcComplexTypeName, String complexTypePropertyName, String complexTypeName, String type, Boolean nullable, Object defaultValue, String collectionKind) { // ??? JSONObject body = new JSONObject(); body.put("Name", complexTypePropertyName); body.put("_ComplexType.Name", complexTypeName); body.put("Type", type); body.put("Nullable", nullable); body.put("DefaultValue", defaultValue); body.put("CollectionKind", collectionKind); // PersoniumRequest req = PersoniumRequest .post(UrlUtils.complexTypeProperty(cell, box, collection, null, null)); req.header(HttpHeaders.AUTHORIZATION, AbstractCase.BEARER_MASTER_TOKEN); req.addStringBody(body.toJSONString()); // return AbstractCase.request(req); }
From source file:it.polimi.geinterface.network.MessageUtils.java
/** * Method building the {@link MessageType#PROX_BEACONS} message containing data about {@link Entity} of type {@link Type#BLE_BEACON} * seen by the sender in last BLE scanning cycles */// ww w .j a va 2 s .c o m public static String buildProxBeaconsMessage(ArrayList<Entity> beacons, Entity e, String logId) { JSONObject msg = new JSONObject(); JSONObject proxMsg = new JSONObject(); proxMsg.put(JsonStrings.SENDER, e.getEntityID()); proxMsg.put(JsonStrings.MSG_TYPE, MessageType.PROX_BEACONS.name()); proxMsg.put(JsonStrings.ENTITY, ((JSONObject) e.getJsonDescriptor().get(JsonStrings.ENTITY))); proxMsg.put(JsonStrings.BEACONS, ((JSONArray) buildBeaconsJsonArray(beacons))); proxMsg.put(JsonStrings.LOG_ID, logId); msg.put(JsonStrings.MESSAGE, proxMsg); return msg.toJSONString(); }
From source file:it.polimi.geinterface.network.MessageUtils.java
/** * Method that builds the {@link MessageType#SYNC_RESP} message corresponding to a {@link MessageType#SYNC_REQ} *//*from w w w . j a v a 2 s . c o m*/ public static String buildSyncRespMessage(Entity e, String topicReply) { JSONObject msg = new JSONObject(); JSONObject syncRespMsg = new JSONObject(); syncRespMsg.put(JsonStrings.SENDER, e.getEntityID()); syncRespMsg.put(JsonStrings.MSG_TYPE, MessageType.SYNC_RESP.name()); /* * Only for logging */ syncRespMsg.put(JsonStrings.TOPIC_REPLY, topicReply); syncRespMsg.put(JsonStrings.ENTITY, ((JSONObject) e.getJsonDescriptor().get(JsonStrings.ENTITY))); msg.put(JsonStrings.MESSAGE, syncRespMsg); return msg.toJSONString(); }
From source file:com.fujitsu.dc.test.utils.CellUtils.java
/** * event?POST?.//from w w w. j a va 2 s .com * @param authorization Authorization?(auth-shema?) * @param code ? * @param cellName ?? * @param level * @param action ? * @param object ? * @param result ?? * @return ? */ @SuppressWarnings("unchecked") public static TResponse eventWithAnyAuthSchema(String authorization, int code, String cellName, String level, String action, String object, String result) { JSONObject body = new JSONObject(); body.put("level", level); body.put("action", action); body.put("object", object); body.put("result", result); return Http.request("cell/cell-event-anyAuthSchema.txt").with("METHOD", HttpMethod.POST) .with("authorization", authorization).with("cellPath", cellName).with("requestKey", "") .with("json", body.toJSONString()).returns().statusCode(code); }
From source file:com.doubotis.restwrapper.data.JObject.java
@Override public String toJSONString() { JSONObject jsonObject = new JSONObject(this); return jsonObject.toJSONString(); }
From source file:naftoreiclag.villagefive.util.json.AbstractJSONThingy.java
public String toJSONString() { JSONObject dummy = new JSONObject(); this.populateJson(dummy); return dummy.toJSONString(); }
From source file:com.fujitsu.dc.test.utils.CellUtils.java
/** * __event/{boxName}?POST?.//from www.j a va 2s . c o m * @param authorization Authorization?(auth-shema?) * @param cellName ?? * @param boxName ?? * @param level * @param action ? * @param object ? * @param result ?? * @return ? * @throws DcException */ @SuppressWarnings("unchecked") public static DcResponse eventUnderBox(String authorization, String cellName, String boxName, String level, String action, String object, String result) throws DcException { JSONObject body = new JSONObject(); body.put("level", level); body.put("action", action); body.put("object", object); body.put("result", result); DcRestAdapter adaper = new DcRestAdapter(); HashMap<String, String> header = new HashMap<String, String>(); header.put(HttpHeaders.AUTHORIZATION, authorization); return adaper.post(UrlUtils.cellRoot(cellName) + "__event/" + boxName, body.toJSONString(), header); }
From source file:com.doubotis.restwrapper.data.JObjectResponse.java
@Override public String toJSONString() { JSONObject jsonObject = new JSONObject(this); return jsonObject.toJSONString(); }
From source file:io.personium.test.utils.CellUtils.java
/** * __event/{boxName}?POST?./*from www. ja va 2s . c o m*/ * @param authorization Authorization?(auth-shema?) * @param cellName ?? * @param boxName ?? * @param level * @param action ? * @param object ? * @param result ?? * @return ? * @throws PersoniumException */ @SuppressWarnings("unchecked") public static PersoniumResponse eventUnderBox(String authorization, String cellName, String boxName, String level, String action, String object, String result) throws PersoniumException { JSONObject body = new JSONObject(); body.put("level", level); body.put("action", action); body.put("object", object); body.put("result", result); PersoniumRestAdapter adaper = new PersoniumRestAdapter(); HashMap<String, String> header = new HashMap<String, String>(); header.put(HttpHeaders.AUTHORIZATION, authorization); return adaper.post(UrlUtils.cellRoot(cellName) + "__event/" + boxName, body.toJSONString(), header); }
From source file:it.polimi.geinterface.network.MessageUtils.java
/** * //from w ww. j a va 2s.co m * Method that builds the message sent to notify a proximity update between two {@link Entity}, containing * the corresponding {@link DistanceRange} */ public static String buildProximityMessage(String senderID, MessageType type, Entity e1, Entity e2, DistanceRange distance, String logId) { JSONObject mesg = new JSONObject(); JSONObject proxMsg = new JSONObject(); proxMsg.put(JsonStrings.SENDER, senderID); proxMsg.put(JsonStrings.MSG_TYPE, type.name()); proxMsg.put(JsonStrings.ENTITY_1, (JSONObject) e1.getJsonDescriptor().get(JsonStrings.ENTITY)); proxMsg.put(JsonStrings.ENTITY_2, (JSONObject) e2.getJsonDescriptor().get(JsonStrings.ENTITY)); proxMsg.put(JsonStrings.DISTANCE_RANGE, distance.name()); proxMsg.put(JsonStrings.LOG_ID, logId); mesg.put(JsonStrings.MESSAGE, proxMsg); return mesg.toJSONString(); }