Как я могу получить данные из запроса используя volley в android?
JSON
[
{
"name":"Spain",
"capital":[
"Madrid"
],
"alphaCode":"ES",
"phoneCodes":[
"34"
]
}
]
java
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject jsonObject = response.getJSONObject("name");
infoTxt.setText(jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
});
requestQueue.add(jsonObjectRequest);