如何解析以下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"
}
]
}
答案 0 :(得分: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");
....
}
答案 1 :(得分:0)
http://dheerajvermadeveloper.blogspot.in/2014/11/android-json-tutorial.html
通过此链接获得Json Parsing的完整教程