-3
[{"id":"1","capacity":"150","type":"conference","prix":"0","description":"description","image":""},{"id":"2","capacity":"200","type":"Formation","prix":"0","description":"desc"}]

How can I get the values of this array on Android?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
GEEK
  • 3
  • 3

1 Answers1

0

Try this code:

try{
        String yourstring = "ADD YOUR JSON ARRAY HERE";
        JSONArray temp = new JSONArray(yourstring);

        for (int i = 0; i < temp.length(); i++) {
            JSONObject row = (JSONObject) temp.get(i);
            String id = row.getString("id");
            String capacity= row.getString("capacity");
            String type= row.getString("type");
            String prix= row.getString("prix");
            String description = row.getString("description");
           // do something with each variable 
        }
}catch(Exception e){
     e.printstacktrace()
}
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Paraskevas Ntsounos
  • 1,755
  • 2
  • 18
  • 34