in my app when i hit an url i am getting a return data as an json array. it is as follows
{"Status":[{ "img_path": "http://xxxxxxxxxxxxxx.com/images/thumb140/1316145577.jpg",
"img_path": "http://xxxxxxxxxxxxxx.com/images/thumb140/1316146270.jpg",
"img_path": "http://xxxxxxxxxxxxxx.com/images/thumb140/1316146473.jpg",
"img_path": "http://xxxxxxxxxxxxxx.com/images/thumb140/1316147003.jpg" } ]}
From the above result i am trying to parse out the urls and i am trying to store it in an array list. Following is my code
try{
JSONArray get_post_status = json.getJSONArray("Status");
for (int i = 0; i < get_post_status.length(); i++) {
JSONObject e = get_post_status.getJSONObject(i);
if(e.equals("img_path"))
{
Get_post_image_array.add(e.getString("img_path"));
}
}
But in my arraylist i am getting only the last url from the result. How to get all the urls in the arraylist.
Pls help me…….
The returned JSON is invalid.
Shortening the data, looking only at the structure:
We can see that the array (enclosed in
[]) only contains one element; the object enclosed by{}. This object has several instances of the same key,"img_path". This is not valid. Your parser apparently ends up with keeping only the last instance of it.The JSON ought to look more like this: