jason数组请求代码如下:
JsonArrayRequest arrayRequest = new JsonArrayRequest(Request.Method.GET,url, (JSONArray) null , new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
Log.d("Response:", String.valueOf(response.getJSONObject(0)));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(context, "Response not recieved", Toast.LENGTH_SHORT).show();
}
});
而且我使用了请求队列的单例实例来获取数据,
AppController.getInstance(context.getApplicationContext()).addToRequestQueue(arrayRequest);
[我正在使用提供大量问题的api服务(api会生成一个url,该url返回JSON对象,一个数组的集合(只需尝试打开url链接,就会看到json数组)]
但是当我运行该应用程序时,请求甚至没有得到响应,程序流进入了错误列表框。
有人可以解释这种行为吗?是因为url提供的JSON数组具有嵌套数组吗?为什么?
我尝试在这里阅读和分析其他问题,可能有同样的问题,但我什么也没发现。
JsonArrayRequest
更改为JsonObjectRequest