Determine if two JSONArrays are similar. They must contain similar sequences. @param other The other JSONArray @return true if they are equal
(Object other)
| 871 | * @return true if they are equal |
| 872 | */ |
| 873 | public boolean similar(Object other) { |
| 874 | if (!(other instanceof JSONArray)) { |
| 875 | return false; |
| 876 | } |
| 877 | int len = this.length(); |
| 878 | if (len != ((JSONArray) other).length()) { |
| 879 | return false; |
| 880 | } |
| 881 | for (int i = 0; i < len; i += 1) { |
| 882 | Object valueThis = this.get(i); |
| 883 | Object valueOther = ((JSONArray) other).get(i); |
| 884 | if (valueThis instanceof JSONObject) { |
| 885 | if (!((JSONObject) valueThis).similar(valueOther)) { |
| 886 | return false; |
| 887 | } |
| 888 | } else if (valueThis instanceof JSONArray) { |
| 889 | if (!((JSONArray) valueThis).similar(valueOther)) { |
| 890 | return false; |
| 891 | } |
| 892 | } else if (!valueThis.equals(valueOther)) { |
| 893 | return false; |
| 894 | } |
| 895 | } |
| 896 | return true; |
| 897 | } |
| 898 | |
| 899 | /** |
| 900 | * Produce a JSONObject by combining a JSONArray of names with the values of |