Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Cómo convertir una respuesta de cadena en un objeto iterable

Estoy tratando de llamar a un punto final de descanso usando Volley (biblioteca HTTP) en la aplicación Android/Java. Aquí está mi código,

 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"); } });

Pero me da un String una respuesta como esta,

 [{"country":"USA","countryCode":"US"},{"country":"India","countryCode":"IN"},{"country":"Brazil","countryCode":"BR"}]

¿Cómo convierto esta String en un objeto itarable?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No hay necesidad de otras bibliotecas además de Volley.

Utilice Volleys JsonArrayRequest para recuperar las respuestas de JSONArray .

 RequestQueue queue = Volley.newRequestQueue(this); String url = "http://my-json-feed"; JsonArrayRequest jsonArrayRequest = new JsonArrayRequest (Request.Method.GET, url, null, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { // do something with the response } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO: Handle error } }); // Add request to queue queue.add(jsonArrayRequest);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!