第一个月
这是我的Json文件,但我想使用Volley laiberry,但不使用原始数组:json.jSONArray帮助我们的java代码是
RequestQueue queue = Volley.newRequestQueue(this);
String url ="http://loclhost:1111/json";
JsonObjectRequest jsonArryRequest =new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonArray = new JSONArray(response.getJSONArray("records").getJSONObject(1));
} catch (JSONException e) {
e.printStackTrace();
Log.d("Papa","Ex - "+e.getMessage());
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
String errorm = error.getMessage();
Log.d("papa", "error : "+errorm);
}
});
queue.add(jsonArryRequest);
1条答案
按热度按时间igetnqfo1#
您正在初始化一个新的jsonArray,这不是正确的方法
而不是这个
这样做
通过这种方式,您还可以将第二个json对象放入
jsonObject
变量中