I haven't been able to find a detailed answer to this question, or at least not one that I can understand.
I'm trying to set up Volley to pull down JSON-objects from iTunes. I then want to parse the objects, to get their image URLs.
So for example, here is am iTunes JSON object URL
String url = "https://itunes.apple.com/search?term=michael+jackson";
So here I've set up my code to get this object (using a tutorial of course)
String url = "https://itunes.apple.com/search?term=michael+jackson";
JsonObjectRequest jsonRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new Downloader.Response.Listener // Cannot resolve symbol Listener
<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// the response is already constructed as a JSONObject!
try {
response = response.getJSONObject("args");
String site = response.getString("site"),
network = response.getString("network");
System.out.println("Site: "+site+"
Network: "+network);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Downloader.Response.ErrorListener // Cannot resolve symbol ErrorListener
() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
});
Volley.newRequestQueue(this).add(jsonRequest);
The very last statement is
Volley.newRequestQueue(this).add(jsonRequest);
Presumably, I now have the JSON-object? But how can I access and parse it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…