public static <T> T parseOptionalJsonObject(final JSONObject json, final String attributeName, final JsonObjectParser<T> jsonParser) throws JSONException { JSONObject attributeObject = getOptionalJsonObject(json, attributeName); return attributeObject != null ? jsonParser.parse(attributeObject) : null; }
@Override public T call() throws Exception { final WebResource webResource = client.resource(uri); final JSONObject postEntity = callable.call(); final JSONObject s; s = doHttpMethod(webResource, postEntity, method); return parser.parse(s); } });
public static <T> T parseOptionalJsonObject(final JSONObject json, final String attributeName, final JsonObjectParser<T> jsonParser) throws JSONException { JSONObject attributeObject = getOptionalJsonObject(json, attributeName); return attributeObject != null ? jsonParser.parse(attributeObject) : null; }
@Nullable public static <T> T getOptionalJsonObject(final JSONObject jsonObject, final String attributeName, final JsonObjectParser<T> jsonParser) throws JSONException { final JSONObject res = jsonObject.optJSONObject(attributeName); if (res == JSONObject.NULL || res == null) { return null; } return jsonParser.parse(res); }
@Nullable private <T> T getOptionalNestedField(final JSONObject s, final String fieldId, final JsonObjectParser<T> jsonParser) throws JSONException { final JSONObject fieldJson = JsonParseUtil.getNestedOptionalObject(s, FIELDS, fieldId); // for fields like assignee (when unassigned) value attribute may be missing completely if (fieldJson != null) { return jsonParser.parse(fieldJson); } return null; }
@Override public T parse(Object o) throws JSONException { return jsonParser.parse(convert(o, JSONObject.class)); } }
@Nullable private <T> T getOptionalNestedField(final JSONObject s, final String fieldId, final JsonObjectParser<T> jsonParser) throws JSONException { final JSONObject fieldJson = JsonParseUtil.getNestedOptionalObject(s, FIELDS, fieldId); // for fields like assignee (when unassigned) value attribute may be missing completely if (fieldJson != null) { return jsonParser.parse(fieldJson); } return null; }
@Override public T call() throws Exception { final WebResource webResource = client.resource(uri); final JSONObject postEntity = callable.call(); final JSONObject s; s = doHttpMethod(webResource, postEntity, method); return parser.parse(s); } });
@Override public T parse(JSONObject json) throws JSONException { final JSONObject valueObject = json.optJSONObject(VALUE_ATTRIBUTE); if (valueObject == null) { throw new JSONException("Expected JSONObject with [" + VALUE_ATTRIBUTE + "] attribute present."); } return jsonParser.parse(valueObject); } }
@Override public Iterable<T> parse(JSONArray json) throws JSONException { ArrayList<T> res = new ArrayList<T>(json.length()); for (int i = 0; i < json.length(); i++) { res.add(jsonParser.parse(json.getJSONObject(i))); } return res; } }
@Override public Iterable<T> parse(JSONArray json) throws JSONException { ArrayList<T> res = new ArrayList<T>(json.length()); for (int i = 0; i < json.length(); i++) { res.add(jsonParser.parse(json.getJSONObject(i))); } return res; } }
@Override public Iterable<T> parse(JSONArray json) throws JSONException { ArrayList<T> res = new ArrayList<T>(json.length()); for (int i = 0; i < json.length(); i++) { res.add(jsonParser.parse(json.getJSONObject(i))); } return res; } }
@Override public T call() throws Exception { final WebResource webResource = client.resource(uri); final JSONObject s = webResource.get(JSONObject.class); return parser.parse(s); } });
@Override public T parse(JSONObject json) throws JSONException { final JSONObject valueObject = json.optJSONObject(VALUE_ATTRIBUTE); if (valueObject == null) { throw new JSONException("Expected JSONObject with [" + VALUE_ATTRIBUTE + "] attribute present."); } return jsonParser.parse(valueObject); } }
@Override public Iterable<T> parse(JSONArray json) throws JSONException { ArrayList<T> res = new ArrayList<T>(json.length()); for (int i = 0; i < json.length(); i++) { res.add(jsonParser.parse(json.getJSONObject(i))); } return res; } }
public static <T> Collection<T> parseJsonArray(JSONArray jsonArray, JsonObjectParser<T> jsonParser) throws JSONException { final Collection<T> res = new ArrayList<T>(jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { res.add(jsonParser.parse(jsonArray.getJSONObject(i))); } return res; }
@Override public T parse(JSONObject json) throws JSONException { final JSONObject valueObject = json.optJSONObject(VALUE_ATTRIBUTE); if (valueObject == null) { throw new JSONException("Expected JSONObject with [" + VALUE_ATTRIBUTE + "] attribute present."); } return jsonParser.parse(valueObject); } }
@Override public T call() throws Exception { final WebResource webResource = client.resource(uri); final JSONObject s = postEntity != null ? webResource.post(JSONObject.class, postEntity) : webResource.post(JSONObject.class); return parser.parse(s); } });
@Override public T call() throws Exception { final WebResource webResource = client.resource(uri); final JSONObject s = postEntity != null ? webResource.post(JSONObject.class, postEntity) : webResource.post(JSONObject.class); return parser.parse(s); } });
@Override public T handle(Response response) throws JSONException, IOException { final String body = response.getEntity(); return (T) (parser instanceof JsonObjectParser ? ((JsonObjectParser) parser).parse(new JSONObject(body)) : ((JsonArrayParser) parser).parse(new JSONArray(body))); } };