private void getJSONByVolley() {
RequestQueue requestQueue = Volley.newRequestQueue(this);
String JSONDataUrl = "网络地址";
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
Method.GET,JSONDataUrl,null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
System.out.println("response="+response);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError arg0) {
System.out.println("sorry,Error");
}
});
requestQueue.add(jsonObjectRequest);
}
先获取json数组中其中一个json对象,再获取对象中的元素