I am trying to call a rest end point using Volley (HTTP library) in Android/Java app. Here is my code,
RequestQueue queue = Volley.newRequestQueue(this);
String url ="https://covid19datasl.herokuapp.com/countries";
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
System.out.println(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
System.out.println("Error");
}
});
But it gives me an String a response like this,
[{"country":"USA","countryCode":"US"},{"country":"India","countryCode":"IN"},{"country":"Brazil","countryCode":"BR"}]
How do I convert this String
to an itaratable object?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…