private Object readByIndexToken ( Object current , String indexToken ) throws JSONPointerException { try { int index = Integer . parseInt ( indexToken ) ; JSONArray currentArr = ( JSONArray ) current ; if ( index >= currentArr . length ( ) ) { throw new JSONPointerException ( format ( "index %s is out of bounds - the array has %d elements" , indexToken , Integer . valueOf ( currentArr . length ( ) ) ) ) ; } try { return currentArr . get ( index ) ; } catch ( JSONException e ) { throw new JSONPointerException ( "Error reading value at index position " + index , e ) ; } } catch ( NumberFormatException e ) { throw new JSONPointerException ( format ( "%s is not an array index" , indexToken ) , e ) ; } }
Matches a JSONArray element by ordinal position