Reputation: 149
I have android AsynTask method that call the Web Service which returns the List<> as shown below:
[[1,"Test",37.334542,-121.890821,-121.890821],
[2,"XYZ",37.337749,-121.886702,-121.886702],
[4,"PQR",37.336453,-121.884985,-121.884985]]
Here my question is how can I convert the response of HttpResponse to List<> as same as shown above.
Upvotes: 0
Views: 1459
Reputation: 4787
That looks like a json response. If it is, the easiest way to do it if you have that String (jsonResponse) already is something like:
JSONArray json;
try {
json = new JSONArray (jsonResponse);
} catch (JSONException e) {
//do something
}
You can then just use the JSONArray as is, or iterate through it and add each item to a List
if you need.
Upvotes: 2