Package ar.com.restba.json

Examples of ar.com.restba.json.JsonObject


      while (i.hasNext()) {
        Map.Entry<Object, Object> e = i.next();
        if (isStandardProperty(e.getValue().getClass())) {
          this.map.put(e.getKey(), e.getValue());
        } else {
          this.map.put(e.getKey(), new JsonObject(e.getValue(), includeSuperClass));
        }
      }
    }
  }
View Full Code Here


            } 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
              map.put(key, result);
            } else {
              if (result.getClass().getPackage().getName().startsWith("java")
                  || result.getClass().getClassLoader() == null) {
                map.put(key, result.toString());
              } else { // User defined Objects
                map.put(key, new JsonObject(result, includeSuperClass));
              }
            }
          }
        }
      } catch (Exception e) {
View Full Code Here

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

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

    }
    if (value instanceof JsonArray) {
      return ((JsonArray) value).toString(indentFactor, indent);
    }
    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()) {
View Full Code Here

      Iterator<?> iter = collection.iterator();
      ;
      while (iter.hasNext()) {
        Object o = iter.next();
        if (o instanceof Map<?, ?>) {
          this.myArrayList.add(new JsonObject((Map<?, ?>) o, includeSuperClass));
        } else if (!JsonObject.isStandardProperty(o.getClass())) {
          this.myArrayList.add(new JsonObject(o, includeSuperClass));
        } else {
          this.myArrayList.add(o);
        }
      }
    }
View Full Code Here

      for (int i = 0; i < length; i += 1) {
        Object o = Array.get(array, i);
        if (JsonObject.isStandardProperty(o.getClass())) {
          this.myArrayList.add(o);
        } else {
          this.myArrayList.add(new JsonObject(o, includeSuperClass));
        }
      }
    } else {
      throw new JsonException("JsonArray initial value should be a string or collection or array.");
    }
View Full Code Here

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

   * @throws JsonException
   *           If the index is negative or if the the value is an invalid
   *           number.
   */
  public JsonArray put(int index, Map<?, ?> value) {
    put(index, new JsonObject(value));
    return this;
  }
View Full Code Here

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

TOP

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

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.