[{"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?
[{"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?
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()
}