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

研究この例http://www.journaldev.com/2321/gson-example-tutorial-parse-json – xbadal

+0

#Chandana_Rajこのタイプはすでにここに尋ねました。 Googleで質問を検索する前に –

+0

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

答えて

2

使用この:質問の

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

@ rafsanahmad007 –

+0

答えの左側のチェックマークをクリックして、正しいとマークするのに役立ちます場合は... thankx。@ Chandana_Raj – rafsanahmad007

+0

ええ完了!私は正しい答えとしてそれをマークしました –

関連する問題