Package ar.com.restba.json

Examples of ar.com.restba.json.JsonArray


            Object result = method.invoke(bean, (Object[]) null);
            if (result == null) {
              map.put(key, NULL);
            } else if (result.getClass().isArray()) {
              map.put(key, new JsonArray(result, includeSuperClass));
            } else if (result instanceof Collection<?>) { // List or Set
              map.put(key, new JsonArray((Collection<?>) result, includeSuperClass));
            } else if (result instanceof Map<?, ?>) {
              map.put(key, new JsonObject((Map<?, ?>) result, includeSuperClass));
            } else if (isStandardProperty(result.getClass())) { // Primitives,
              // String and
              // Wrapper
View Full Code Here


   */
  public JsonObject accumulate(String key, Object value) {
    testValidity(value);
    Object o = opt(key);
    if (o == null) {
      put(key, value instanceof JsonArray ? new JsonArray().put(value) : value);
    } else if (o instanceof JsonArray) {
      ((JsonArray) o).put(value);
    } else {
      put(key, new JsonArray().put(o).put(value));
    }
    return this;
  }
View Full Code Here

   */
  public JsonObject append(String key, Object value) {
    testValidity(value);
    Object o = opt(key);
    if (o == null) {
      put(key, new JsonArray().put(value));
    } else if (o instanceof JsonArray) {
      put(key, ((JsonArray) o).put(value));
    } else {
      throw new JsonException("JsonObject[" + key + "] is not a JsonArray.");
    }
View Full Code Here

   *
   * @return A JsonArray containing the key strings, or null if the JsonObject
   *         is empty.
   */
  public JsonArray names() {
    JsonArray ja = new JsonArray();
    Iterator<?> keys = keys();
    while (keys.hasNext()) {
      ja.put(keys.next());
    }
    return ja.length() == 0 ? null : ja;
  }
View Full Code Here

   *          A Collection value.
   * @return this.
   * @throws JsonException
   */
  public JsonObject put(String key, Collection<?> value) {
    put(key, new JsonArray(value));
    return this;
  }
View Full Code Here

   */
  public JsonArray toJsonArray(JsonArray names) {
    if (names == null || names.length() == 0) {
      return null;
    }
    JsonArray ja = new JsonArray();
    for (int i = 0; i < names.length(); i += 1) {
      ja.put(this.opt(names.getString(i)));
    }
    return ja;
  }
View Full Code Here

    }
    if (value instanceof Map<?, ?>) {
      return new JsonObject((Map<?, ?>) value).toString();
    }
    if (value instanceof Collection<?>) {
      return new JsonArray((Collection<?>) value).toString();
    }
    if (value.getClass().isArray()) {
      return new JsonArray(value).toString();
    }
    return quote(value.toString());
  }
View Full Code Here

    }
    if (value instanceof Map<?, ?>) {
      return new JsonObject((Map<?, ?>) value).toString(indentFactor, indent);
    }
    if (value instanceof Collection<?>) {
      return new JsonArray((Collection<?>) value).toString(indentFactor, indent);
    }
    if (value.getClass().isArray()) {
      return new JsonArray(value).toString(indentFactor, indent);
    }
    return quote(value.toString());
  }
View Full Code Here

   * @param value
   *          A Collection value.
   * @return this.
   */
  public JsonArray put(Collection<?> value) {
    put(new JsonArray(value));
    return this;
  }
View Full Code Here

   * @return this.
   * @throws JsonException
   *           If the index is negative or if the value is not finite.
   */
  public JsonArray put(int index, Collection<?> value) {
    put(index, new JsonArray(value));
    return this;
  }
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.