Android JSON Array to List parseJSONArrayToList(JSONArray jsa)

Here you can find the source of parseJSONArrayToList(JSONArray jsa)

Description

parse JSON Array To List

Declaration

public static ArrayList<Integer> parseJSONArrayToList(JSONArray jsa) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;

public class Main {

    public static ArrayList<Integer> parseJSONArrayToList(JSONArray jsa) {
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < jsa.length(); i++) {
            try {
                list.add(jsa.getInt(i));

            } catch (JSONException e) {
                e.printStackTrace();/*from w  w w . ja va 2s .  co m*/
            }
        }
        return list;
    }
}