-1

Here is my json structure:

[{"id":"112","image_data":"http:\/\/elogistic.890m.com\/images\/111.png","image_tag":"232188933"},{"id":"113","image_data":"http:\/\/elogistic.890m.com\/images\/112.png","image_tag":"232188933"},{"id":"114","image_data":"http:\/\/elogistic.890m.com\/images\/113.png","image_tag":"232188933"}]

How can I get String "image_data" for each object per String ? example :

String 1 = "image_data"of object1
String 2 = "image_data"of object2

Thanks so much

Zoe
  • 27,060
  • 21
  • 118
  • 148

1 Answers1

1

Try below code. this the example of getting an imagedata from your response you need to modify it as per your requirements

 try {
            JSONArray jsonArray = new JSONArray(Your Json Array String);
            ArrayList<String> imgData = new ArrayList<>();

            for (int i=0; i<jsonArray.length();i++){
                JSONObject jsonObject = jsonArray.getJSONObject(i);
               imgData.add(jsonObject.getString("image_data"));
            }

            String imgData1 = imgData.get(0);
            String imgData2 = imgData.get(1);

        } catch (JSONException e) {
            e.printStackTrace();
        }
Munir
  • 2,548
  • 1
  • 11
  • 20