Package ar.com.restba.json

Examples of ar.com.restba.json.JsonArray


      back();
      return new JsonObject(this);
    case '[':
    case '(':
      back();
      return new JsonArray(this);
    }

    /*
     * Handle unquoted text. This could be the values true, false, or null, or
     * it can be a number. An implementation (such as this one) is allowed to
View Full Code Here


    // Pull out data
    JsonObject hits = jsonObject.getJsonObject("hits");
    long total = hits.getLong("total");
    maxPages = ((int) Math.ceil(total / 10.0));

    JsonArray jsonData = hits.getJsonArray("hits");

    for (int i = 0; i < jsonData.length(); i++) {
      T t;
      JsonObject objectToMap = jsonData.getJsonObject(i).getJsonObject(
          "_source");
      String id = jsonData.getJsonObject(i).getString("_id");
      objectToMap.putOnce("_id", id);
      if (connectionType.equals(ar.com.restba.json.JsonObject.class)) {
        t = (T) objectToMap;
      } else if (connectionType.equals(com.restfb.json.JsonObject.class)) {
        throw new RestBAException(
View Full Code Here

    }

    try {
      List<T> list = new ArrayList<T>();

      JsonArray jsonArray = new JsonArray(json);
      for (int i = 0; i < jsonArray.length(); i++)
        list.add(toJavaObject(jsonArray.get(i).toString(), type));

      return unmodifiableList(list);
    } catch (FacebookJsonMappingException e) {
      throw e;
    } catch (Exception e) {
View Full Code Here

            + QUERIES_PARAM_NAME + "' URL parameter yourself - "
            + "RestFB will populate this for you with "
            + "the queries you passed to this method.");

    try {
      JsonArray jsonArray = new JsonArray(makeRequest(
          "fql.multiquery",
          false,
          false,
          null,
          parametersWithAdditionalParameter(Parameter.with(
              QUERIES_PARAM_NAME, queriesToJson(queries)),
              parameters)));

      JsonObject normalizedJson = new JsonObject();

      for (int i = 0; i < jsonArray.length(); i++) {
        JsonObject jsonObject = jsonArray.getJsonObject(i);

        // For empty resultsets, Facebook will return an empty object
        // instead of
        // an empty list. Hack around that here.
        JsonArray resultsArray = jsonObject.get("fql_result_set") instanceof JsonArray ? jsonObject
            .getJsonArray("fql_result_set") : new JsonArray();

        normalizedJson.put(jsonObject.getString("name"), resultsArray);
      }

      return objectType.equals(JsonObject.class) ? (T) normalizedJson
View Full Code Here

  protected Object toJsonInternal(Object object, boolean ignoreNullValuedProperties) {
    if (object == null)
      return NULL;

    if (object instanceof List<?>) {
      JsonArray jsonArray = new JsonArray();
      for (Object o : (List<?>) object)
        jsonArray.put(toJsonInternal(o, ignoreNullValuedProperties));

      return jsonArray;
    }

    if (object instanceof Map<?, ?>) {
View Full Code Here

            + Comments.class.getSimpleName() + " object instead.  Working around that " + "by coercing into an empty "
            + Comments.class.getSimpleName() + " instance...");

      JsonObject workaroundJsonObject = new JsonObject();
      workaroundJsonObject.put("count", 0);
      workaroundJsonObject.put("data", new JsonArray());
      rawValueAsString = workaroundJsonObject.toString();
    }

    // Some other type - recurse into it
    return toJavaObject(rawValueAsString, type);
View Full Code Here

TOP

Related Classes of ar.com.restba.json.JsonArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.