Example #1
0
  public final void acceptVisitor(JSONVisitor visitor) {
    visitor.visitObjectBeforeChildren(this);

    java.util.ArrayList<String> keys = this.keys();

    int keysCount = keys.size();
    for (int i = 0; i < keysCount; i++) {
      if (i != 0) {
        visitor.visitObjectInBetweenChildren(this);
      }
      String key = keys.get(i);
      visitor.visitObjectBeforeChild(this, key);
      final JSONBaseObject child = get(key);
      child.acceptVisitor(visitor);
    }

    visitor.visitObjectAfterChildren(this);
  }
Example #2
0
  public final JSONObject deepCopy() {
    JSONObject result = new JSONObject();

    java.util.ArrayList<String> keys = this.keys();

    int keysCount = keys.size();
    for (int i = 0; i < keysCount; i++) {
      String key = keys.get(i);
      result.put(key, JSONBaseObject.deepCopy(get(key)));
    }

    return result;
  }
Example #3
0
 public final JSONString getAsString(String key) {
   final JSONBaseObject object = get(key);
   return (object == null) ? null : object.asString();
 }
Example #4
0
 public final JSONNumber getAsNumber(String key) {
   final JSONBaseObject object = get(key);
   return (object == null) ? null : object.asNumber();
 }
Example #5
0
 public final JSONBoolean getAsBoolean(String key) {
   final JSONBaseObject object = get(key);
   return (object == null) ? null : object.asBoolean();
 }
Example #6
0
 public final JSONArray getAsArray(String key) {
   final JSONBaseObject object = get(key);
   return (object == null) ? null : object.asArray();
 }
Example #7
0
 public final JSONObject getAsObject(String key) {
   final JSONBaseObject object = get(key);
   return (object == null) ? null : object.asObject();
 }