我正在尝试使用org.json中的类从以下json对象获取可用数字列表
{
"response":true,
"state":1,
"data":
{
"CALLERID":"81101099",
"numbers":
[
"21344111","21772917",
"28511113","29274472",
"29843999","29845591",
"30870001","30870089",
"30870090","30870091"
]
}
}
在从Web服务接收到json对象后,我的第一步是:
jsonObj = new JSONObject(response);
jsonData = jsonObj.optJSONObject("data");
现在,如何保存数字的字符串数组?
解决方法:
采用:
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);
标签:android,json
来源: https://codeday.me/bug/20191005/1857650.html