Tuesday, 7 July 2015

Simple function to concatenate 'n' number of JSONArrays



private JSONArray concatJSONArray(JSONArray... arrs) throws JSONException {
    JSONArray result = new JSONArray();
    for (JSONArray arr : arrs) {
        for (int i = 0; i < arr.length(); i++) {
            result.put(arr.get(i));
        }
    }
    return result;


Example: JSONArray result= concatJSONArray(JSONArray array1,JSONArray array2);

No comments:

Post a Comment