moayed ayasaa moayed ayasaa - 1 year ago 111
Android Question

How to parse image from jsonarray and display using Picasso

I have this JSON data

I have to parse the

that with key "im:image" that has 3 links of image and display it using Picasso library.

Any ideas? Thanks in advance.

Answer Source

Try the following

try {
    JSONObject jsonFeed = new JSONObject(your_original_json).getJSONObject("feed");
    JSONArray entries = jsonFeed.getJSONArray("entry");
    int count = entries.length();
    for (int i = 0; i < count; i++) {
        JSONObject imageJson = entries.getJSONObject(i).getJSONObject("im:image");
        // in case you want to get image with height 53
        String imageUrl = imageJson.getJSONObject("0").getString("label");

        // String imageUrl = imageJson.getJSONObject("1").getString("label"); height 75
        // String imageUrl = imageJson.getJSONObject("2").getString("label"); height 100
} catch (JSONException e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download