/** * set the order the comments are sorted */ private void fillOrder(JsonObject summary) { if (summary != null) { order = summary.getString("order", order); } if (order == null && openGraphCommentOrder != null) { order = openGraphCommentOrder; } }
return new Double(jsonObject.getDouble(facebookFieldName)); if (Float.class.equals(type) || Float.TYPE.equals(type)) return new BigDecimal(jsonObject.getString(facebookFieldName)).floatValue(); if (BigInteger.class.equals(type)) return new BigInteger(jsonObject.getString(facebookFieldName)); if (BigDecimal.class.equals(type)) return new BigDecimal(jsonObject.getString(facebookFieldName)); if (List.class.equals(type)) return toJavaList(rawValue.toString(), getFirstParameterizedTypeArgument(fieldWithAnnotation.getField()));
protected ExceptionInformation createFacebookResponseTypeAndMessageContainer(JsonObject errorObject, Integer httpStatusCode) { JsonObject innerErrorObject = errorObject.get(ERROR_ATTRIBUTE_NAME).asObject(); // If there's an Integer error code, pluck it out. Integer errorCode = innerErrorObject.get(ERROR_CODE_ATTRIBUTE_NAME) != null ? toInteger(innerErrorObject.get(ERROR_CODE_ATTRIBUTE_NAME).toString()) : null; Integer errorSubcode = innerErrorObject.get(ERROR_SUBCODE_ATTRIBUTE_NAME) != null ? toInteger(innerErrorObject.get(ERROR_SUBCODE_ATTRIBUTE_NAME).toString()) : null; return new ExceptionInformation(errorCode, errorSubcode, httpStatusCode, innerErrorObject.getString(ERROR_TYPE_ATTRIBUTE_NAME, null), innerErrorObject.get(ERROR_MESSAGE_ATTRIBUTE_NAME).asString(), innerErrorObject.getString(ERROR_USER_TITLE_ATTRIBUTE_NAME, null), innerErrorObject.getString(ERROR_USER_MSG_ATTRIBUTE_NAME, null), innerErrorObject.getBoolean(ERROR_IS_TRANSIENT_NAME, false), errorObject); }
@SuppressWarnings("unchecked") protected <T> Connection<T> mapToConnection(String connectionJson, Class<T> connectionType) { List<T> data = new ArrayList<T>(); String previous = null; String next = null; try { JsonObject jsonObject = new JsonObject(connectionJson); // Pull out data JsonArray jsonData = jsonObject.getJsonArray("data"); for (int i = 0; i < jsonData.length(); i++) data.add(connectionType.equals(JsonObject.class) ? (T) jsonData.get(i) : jsonMapper.toJavaObject(jsonData .get(i).toString(), connectionType)); // Pull out paging info, if present if (jsonObject.has("paging")) { JsonObject jsonPaging = jsonObject.getJsonObject("paging"); previous = jsonPaging.has("previous") ? jsonPaging.getString("previous") : null; next = jsonPaging.has("next") ? jsonPaging.getString("next") : null; } } catch (JsonException e) { throw new FacebookJsonMappingException("Unable to map connection JSON to Java objects", e); } return new Connection<T>(data, previous, next); }
errorObject.getString(LEGACY_ERROR_MSG_ATTRIBUTE_NAME)); } catch (JsonException e) { throw new FacebookJsonMappingException("Unable to process the Facebook API response", e);
: new JsonArray(); normalizedJson.put(jsonObject.getString("name"), resultsArray);
/** * Gets the Facebook API error {@code fbtrace_id}. * * Internal support identifier. When reporting a bug related to a Graph API call, include the fbtrace_id to help us * find log data for debugging. * * @return the Facebook API error {@code fbtrace_id} */ public String getFbtraceId() { if (getRawErrorJson() != null && getRawErrorJson().get("error").isObject()) { JsonObject errorJson = getRawErrorJson().get("error").asObject(); return errorJson.getString("fbtrace_id", ""); } return ""; }
@Override public void throwBatchFacebookResponseStatusExceptionIfNecessary(String json, Integer httpStatusCode) { try { skipResponseStatusExceptionParsing(json); JsonObject errorObject = silentlyCreateObjectFromString(json); if (errorObject == null || errorObject.get(BATCH_ERROR_ATTRIBUTE_NAME) == null || errorObject.get(BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME) == null) return; ExceptionInformation container = new ExceptionInformation(errorObject.getInt(BATCH_ERROR_ATTRIBUTE_NAME, 0), httpStatusCode, errorObject.getString(BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME, null), errorObject); throw graphFacebookExceptionMapper.exceptionForTypeAndMessage(container); } catch (ParseException e) { throw new FacebookJsonMappingException("Unable to process the Facebook API response", e); } catch (ResponseErrorJsonParsingException ex) { // do nothing here } }
String algorithm = payloadObject.getString("algorithm", null);
: new JsonArray(); normalizedJson.put(jsonObject.getString("name"), resultsArray);