public boolean similar ( Object other ) { if ( ! ( other instanceof JSONArray ) ) { return false ; } int len = this . length ( ) ; if ( len != ( ( JSONArray ) other ) . length ( ) ) { return false ; } for ( int i = 0 ; i < len ; i += 1 ) { Object valueThis = this . get ( i ) ; Object valueOther = ( ( JSONArray ) other ) . get ( i ) ; if ( valueThis instanceof JSONObject ) { if ( ! ( ( JSONObject ) valueThis ) . similar ( valueOther ) ) { return false ; } } else if ( valueThis instanceof JSONArray ) { if ( ! ( ( JSONArray ) valueThis ) . similar ( valueOther ) ) { return false ; } } else if ( ! valueThis . equals ( valueOther ) ) { return false ; } } return true ; }
Determine if two JSONArrays are similar . They must contain similar sequences .