我的代码:
JSONObject data = {"result":{"a":[{"artist":"Aney","number:"1"},{"artist":"Aney","number:"2"}],"b":[{"artist":"Boney","number:"3"},{"artist":"Boney","number:"4"}], ....
JSONObject obj = new JSONObject(data.toString());
JSONArray tasks = obj.optJSONArray("result");
但是tasks
返回null
。
我尝试了下面的代码,但它不起作用:
JSONObject data = {"result":{"a":[{"artist":"Money",...
JSONArray tasks = data.optJSONArray("result");
更新:
我的主要代码是:
// get data from main url and reutnr array
JSONArray tasks = data.optJSONArray("result");
if(alert){
// get data from another url and return object
JSONObject data = {"result":{"a":[{"artist":"Money",...
tasks = data.optJSONArray("result");
}
// now i use tasks in my code
if(tasks.length() > 0){
....
}
https://stackoverflow.com/questions/51180601
复制相似问题