2012-09-18 55 views
1

如何解析下面的JSON?在JSONArray中具有JSON對象的JSON解析

{ 
    "Servicedata": [ 
     { 
      "services_id": "1", 
      "services_servicename": "a", 
      "service_subscribed": "true" 
     }, 
     { 
      "services_id": "5", 
      "services_servicename": "a", 
      "service_subscribed": "false" 
     }, 
     { 
      "services_id": "2", 
      "services_servicename": "b", 
      "service_subscribed": "true" 
     }, 
     { 
      "services_id": "3", 
      "services_servicename": "c", 
      "service_subscribed": "false" 
     }, 
     { 
      "services_id": "4", 
      "services_servicename": "d", 
      "service_subscribed": "false" 
     }, 
     { 
      "services_id": "6", 
      "services_servicename": "service for test", 
      "service_subscribed": "false" 
     } 
    ] 
} 

回答

5

http://www.androidhive.info/2012/01/android-json-parsing-tutorial/

JSONObject object = new JSONObject(yourstring); 
JSONArray values = object.getJSONArray("Servicedata"); 
for(int i = 0 ; i < values.length(); i++){ 
    JSONObject object1 = values.get(i); 
    String id = object1.getString("services_id"); 
    .... 
} 
+0

應在for循環什麼完全教程? – Rahulkapil

+0

閱讀數組中的earch條目..更新了我的回答 – Nermeen

+0

很棒.... thanxx很多 – Rahulkapil