public static Map<Object, JSONObject> arrayOfJsonObjectToMap(JSONArray array, String uniqueKey) throws JSONException {
        Map<Object, JSONObject> valueMap = new HashMap<Object, JSONObject>();
        for (int i = 0; i < array.length(); ++i) {
            JSONObject jsonObject = (JSONObject) array.get(i);
            Object id = jsonObject.get(uniqueKey);
            valueMap.put(id, jsonObject);
        }
        return valueMap;
    }
public static Map < Object , JSONObject > arrayOfJsonObjectToMap ( JSONArray array , String uniqueKey ) throws JSONException { Map < Object , JSONObject > valueMap = new HashMap < Object , JSONObject > ( ) ; for ( int i = 0 ; i < array . length ( ) ; ++ i ) { JSONObject jsonObject = ( JSONObject ) array . get ( i ) ; Object id = jsonObject . get ( uniqueKey ) ; valueMap . put ( id , jsonObject ) ; } return valueMap ; }
Converts the provided {@link JSONArray} to a Map of {@link JSONObject}s where the key of each object
is the value at {@code uniqueKey} in each object.

@param array     the JSON array to convert
@param uniqueKey the key to map the JSON objects to
@return the map of {@link JSONObject}s from {@code array}
@throws JSONException JSON parsing error