Reputation: 345
I have a trouble to parse this piece of JSON
{
"00408C88A2E6": {
"id": "00408C88A2E6",
"name": "pippo"},
"00408C91188B": {
"id": "00408C91188B",
"name": "pluto"
},
"00408C944B99": {
"id": "00408C944B99",
"name": "minni"
},
"00408C944BA0": {
"id": "00408C944BA0",
"name": "topolino"
}
I need to get all the key "id" and "name", I tried with an iterator but I was able to retrive just the first dicts (00408C88A2E6,00408C91188B...), could anyone give me any hint? Thank you
Edit: I'm using org.json and to parse this I tried in this way
JSONObject jsonChannels = getHttpJson(url_user_cam);
ArrayList<String> al = new ArrayList<String>();
Log.i(LOG_TAG, jsonChannels.toString());
try{
Iterator<String> iterator = jsonChannels.keys();
while (iterator.hasNext() ){
al.add(iterator.next());
}
}catch(Exception e){
Log.e(LOG_TAG, e.toString());
}
with this piece of code my intent is to get the first dict ("00408C88A2E6") after make it I need to access to "id" and "name" element, hwo can i do it?
Upvotes: 0
Views: 990
Reputation: 21733
As pointed in the comments, it looks like your JSON is incomplete. Maybe a pasting error ?
Do you do it manually or do you use a library ?
Have you tried using the "official" Java JSON package ?
Upvotes: 1