Wednesday, April 10, 2024

Java Function to Convert JSON Array to ArrayList


import org.json.JSONArray;
    
public static ArrayList toStringArray(JSONArray array) {
    if(array==null)
        return new ArrayList();
    
    ArrayList l = new ArrayList();
    for(int i=0; i<array.length(); i++) {
        l.add( array.optString(i) );
    }
    return l;
}

No comments:

Followers