I have a question about how parsing json file. My json structure is like this:
{
"contacts": [
{
"id": "c200",
"name": "Ravi Tamada",
"email": "ravi@gmail.com",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"services": [
"laundry",
"wifi",
"tv",
"swimming pool",
"bar"
],
"phone": [
910000000000,
00000000,
000000
]
},
{
"id": "c201",
"name": "Johnny Depp",
"email": "johnny_depp@gmail.com",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"services": [
"laundry",
"wifi",
"tv",
"swimming pool",
"bar"
],
"phone": [
0000000000,
00000000,
00000000
]
}
]
How can I get the phone values and the services values?
phones = jsonObj.getJSONArray(TAG_PHONE);
for (int x = 0; x < phones.length(); x++) {
}
because to get the ID for example I haven´t got problems:
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
String id = c.getString(TAG_ID);
// tmp hashmap for single contact
HashMap<String, String> contact = new HashMap<String, String>();
// adding each child node to HashMap key => value
contact.put(TAG_ID, id);
contactList.add(contact);
Thank you very much