コード例 #1
0
ファイル: JsonComparator.java プロジェクト: Jaxo/jaxogram
  @SuppressWarnings("rawtypes")
  private boolean isEqualsJsonObject(JSONObject a, JSONObject b) {
    if (policy == STRICT) {
      if (a.length() != b.length()) {
        return false;
      }
    }

    if (policy == SIMPLE) {
      if (a.length() > b.length()) {
        return false;
      }
    }

    Enumeration keys = a.keys();
    while (keys.hasMoreElements()) {
      String key = (String) keys.nextElement();
      if (!b.has(key)) {
        return false;
      }
      try {
        if (!isEquals(a.get(key), b.get(key))) {
          return false;
        }
      } catch (JSONException e) {
        return false;
      }
    }

    return true;
  }