/** * Constructor from a JSON tokener. * * @param jsonTokener * The JSON tokener. */ public JsonRepresentation(JSONTokener jsonTokener) { super(MediaType.APPLICATION_JSON); init(jsonTokener); }
/** * * @param jsonObject */ private void init(Object jsonObject) { setCharacterSet(CharacterSet.UTF_8); this.jsonValue = jsonObject; this.indenting = false; this.indentingSize = 3; }
@Get public JSONObject getIp(JsonRepresentation j) throws JSONException { JSONObject request = j.getJsonObject(); . . . }
@Override public Representation toRepresentation(Object source, Variant target, Resource resource) { Representation result = null; if (source instanceof JSONArray) { result = new JsonRepresentation((JSONArray) source); } else if (source instanceof JSONObject) { result = new JsonRepresentation((JSONObject) source); } else if (source instanceof JSONTokener) { result = new JsonRepresentation((JSONTokener) source); } return result; }
@Put("json") public String update(JsonRepresentation foos) { JSONArray fooArray = foos.getJsonArray(); // ... }
/** * Get JSON text from the Representation entity * @param entity json * @return String or null */ private String getJSONText(JsonRepresentation entity) { try { return entity.getText(); } catch (Exception e) { return null; } } }
@Override public Representation toRepresentation(Object source, Variant target, Resource resource) { Representation result = null; if (source instanceof JSONArray) { result = new JsonRepresentation((JSONArray) source); } else if (source instanceof JSONObject) { result = new JsonRepresentation((JSONObject) source); } else if (source instanceof JSONTokener) { result = new JsonRepresentation((JSONTokener) source); } return result; }
/** * Constructor from a JSON tokener. * * @param jsonTokener * The JSON tokener. */ public JsonRepresentation(JSONTokener jsonTokener) { super(MediaType.APPLICATION_JSON); init(jsonTokener); }
/** * * @param jsonObject */ private void init(Object jsonObject) { setCharacterSet(CharacterSet.UTF_8); this.jsonValue = jsonObject; this.indenting = false; this.indentingSize = 3; }
/** * Constructor from a JSON object. * * @param jsonObject * The JSON object. */ public JsonRepresentation(JSONObject jsonObject) { super(MediaType.APPLICATION_JSON); init(jsonObject); }
/** * * @param jsonObject */ private void init(Object jsonObject) { setCharacterSet(CharacterSet.UTF_8); this.jsonValue = jsonObject; this.indenting = false; this.indentingSize = 3; }
/** * Constructor from a JSON object. * * @param jsonObject * The JSON object. */ public JsonRepresentation(JSONObject jsonObject) { super(MediaType.APPLICATION_JSON); init(jsonObject); }
/** * Constructor from a JSON tokener. * * @param jsonTokener * The JSON tokener. */ public JsonRepresentation(JSONTokener jsonTokener) { super(MediaType.APPLICATION_JSON); init(jsonTokener); }
/** * Constructor from a JSON stringer. * * @param jsonStringer * The JSON stringer. */ public JsonRepresentation(JSONStringer jsonStringer) { super(MediaType.APPLICATION_JSON); init(jsonStringer); }
/** * Constructor from a JSON stringer. * * @param jsonStringer * The JSON stringer. */ public JsonRepresentation(JSONStringer jsonStringer) { super(MediaType.APPLICATION_JSON); init(jsonStringer); }
/** * Constructor from a JSON array. * * @param jsonArray * The JSON array. */ public JsonRepresentation(JSONArray jsonArray) { super(MediaType.APPLICATION_JSON); init(jsonArray); }
/** * Constructor from a JSON array. * * @param jsonArray * The JSON array. */ public JsonRepresentation(JSONArray jsonArray) { super(MediaType.APPLICATION_JSON); init(jsonArray); }
/** * Constructor from a JSON array. * * @param jsonArray * The JSON array. */ public JsonRepresentation(JSONArray jsonArray) { super(MediaType.APPLICATION_JSON); init(jsonArray); }
/** * Constructor from a JSON object. * * @param jsonObject * The JSON object. */ public JsonRepresentation(JSONObject jsonObject) { super(MediaType.APPLICATION_JSON); init(jsonObject); }
/** * Constructor from a JSON stringer. * * @param jsonStringer * The JSON stringer. */ public JsonRepresentation(JSONStringer jsonStringer) { super(MediaType.APPLICATION_JSON); init(jsonStringer); }