2017-03-23 1 views
1
{ 
    "terms": [{ 
     "offset": 0, 
     "value": "Nerkundram" 
    }, { 
     "offset": 12, 
     "value": "Chennai" 
    }, { 
     "offset": 21, 
     "value": "Tamil Nadu" 
    }, { 
     "offset": 33, 
     "value": "India" 
    }] 
} 
+0

Studie dieses Beispiel http://www.journaldev.com/2321/gson-example-tutorial-parse-json – xbadal

+0

#Chandana_Raj Diese Art der Frage bereits hier gebeten. Bevor Sie Frage Suche auf Google –

+0

http://stackoverflow.com/questions/6118708/determine-whether-json-is-ajsonobject-or-jsonarray?rq=1 – xbadal

Antwort

2

verwenden:

try{ 
JSONObject json = new JSONObject(jsonString); 
JSONArray jsonArray = json.getJSONArray("terms"); 
for(int i=0;i<jsonArray.length();i++){ 
    JSONObject object = jsonArray.getJSONObject(i); 
    String offset = object.getString("offset"); 
    String value = object.getString("value"); 
    //rest of the strings.. 
    } 
} 
catch (JSONException e){ 
     e.printStackTrace(); 
} 
+0

danke für Ihre Antwort @ rafsanahmad007 –

+0

wenn die Antwort hilft markieren Sie es als richtig, indem Sie auf das Häkchen links neben der Antwort ... thankx. @ Chandana_Raj – rafsanahmad007

+0

yeah done! Ich habe es als richtige Antwort markiert –

Verwandte Themen