1

如何解析以下 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"
        }
    ]
}
4

2 回答 2

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");
    ....
}
于 2012-09-18T11:38:27.120 回答
0

http://dheerajvermadeveloper.blogspot.in/2014/11/android-json-tutorial.html

通过这个链接有完整的 Json Parsing 教程

于 2015-04-09T12:47:32.117 回答