I have fast solution. Just create a file ArrayUtil.java
import java.util.ArrayList;
import java.util.Collection;
import org.json.JSONArray;
import org.json.JSONException;
public class ArrayUtil
{
public static ArrayList<Object> convert(JSONArray jArr)
{
ArrayList<Object> list = new ArrayList<Object>();
try {
for (int i=0, l=jArr.length(); i<l; i++){
list.add(jArr.get(i));
}
} catch (JSONException e) {}
return list;
}
public static JSONArray convert(Collection<Object> list)
{
return new JSONArray(list);
}
}
Usage:
ArrayList<Object> list = ArrayUtil.convert(jArray);
or
JSONArray jArr = ArrayUtil.convert(list);