如何在android中解析来自facebook的json响应

时间:2014-05-05 05:44:29

标签: android json

以下是我从facebook获得的回复我想解析它并且只是得到"数据" :

{Response:  responseCode: 200, graphObject: GraphObject
 {   
   graphObjectClass=GraphObject, state= {"data":[{"id":"544335545"},
   {"id":"546107794"},
   {"id":"567096700"},
   {"id":"584136789"},
   {"id":"586311098"},
   {"id":"590153482"},
   {"id":"592358568"},
   {"id":"593417823"},
   {"id":"593960664"},
   {"id":"608369788"}],
    "paging":{"next":"https:\/\/graph.facebook.com\/v1.0\/100000410265937\/friends?  
fields=id&format=json&access_token=CAAHqMWZBSop0BALK3izq04CPxR14mSsBvZAboLMm0h2EdGCiZBP2Q8B   YhDdVCY6tyGaZBAk1gQEacYZCrYobVZAsfdYvZBnqeK2l5OD0HnfdnKfZAiP2NmqcBn4bzS2AmPcxZA7pQVf5ZC2N4G    v3oUHmZBi77OcooZCiUQy97HEfqwnCLXH0yXzq7efv2hbrZBuxfI9Min2unWuuuE0KYbQb0mQ7ce22s2x8mdAaNgFHI   jQRJEAZDZD&limit=5000&offset=5000&__after_id=enc_AeyIMOiqKCWGFRoCSHoxByFx8J0dzzfH6-   z1gL0LMcdjxqXhXBYlV7tYcFexltaF3AsUBykbDoRGR7cN1-NAYydA"}}}, error: null, isFromCache:false}

请帮忙解决这个问题。

1 个答案:

答案 0 :(得分:0)

试试这个:

JSONObject  jsonObj = new JSONObject(json);
JSONObject japp = jsonObj.getJSONObject("Response");
JSONObject jst = japp.getJSONObject("state");
JSONArray jarry = jst.getJSONArray("data");

for(int i=0; i<jarry.length();i++){

 // your code
}