@SuppressWarnings("unchecked")
    public static <T> T[] jsonArrayToArray(final JSONArray jsonArray, final Class<? extends T[]> newType) {
        if (null == jsonArray) {
            return (T[]) new Object[]{};
        }

        final int newLength = jsonArray.length();
        final Object[] original = new Object[newLength];

        for (int i = 0; i < newLength; i++) {
            original[i] = jsonArray.opt(i);
        }

        return Arrays.copyOf(original, newLength, newType);
    }
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] jsonArrayToArray ( final JSONArray jsonArray , final Class < ? extends T [ ] > newType ) { if ( null == jsonArray ) { return ( T [ ] ) new Object [ ] { } ; } final int newLength = jsonArray . length ( ) ; final Object [ ] original = new Object [ newLength ] ; for ( int i = 0 ; i < newLength ; i ++ ) { original [ i ] = jsonArray . opt ( i ) ; } return Arrays . copyOf ( original , newLength , newType ) ; }
Converts the specified {@link JSONArray JSON array} to an array.

@param <T>       the type of elements maintained by the specified json array
@param jsonArray the specified json array
@param newType   the class of the copy to be returned
@return an array