如何从此json对象中提取字符串数组?

Cod*_*ate 12 android json

我试图从以下json对象获取可用数字列表,使用类来自 org.json

    {
        "response":true,
        "state":1,
        "data":
        {
            "CALLERID":"81101099",
            "numbers":
                [
                       "21344111","21772917",
                       "28511113","29274472",
                       "29843999","29845591",
                       "30870001","30870089",
                       "30870090","30870091"
                ]
        }
    }
Run Code Online (Sandbox Code Playgroud)

在从Web服务接收到json对象后,我的第一步是:

jsonObj = new JSONObject(response);
jsonData = jsonObj.optJSONObject("data");
Run Code Online (Sandbox Code Playgroud)

现在,如何保存数字的字符串数组?

jee*_*eet 37

使用:

jsonObj = new JSONObject(response);
jsonData = jsonObj.optJSONObject("data");
JSONArray arrJson = jsonData.getJSONArray("numbers");
String[] arr = new String[arrJson.length()];
for(int i = 0; i < arrJson.length(); i++)
    arr[i] = arrJson.getString(i);
Run Code Online (Sandbox Code Playgroud)