기본적으로 안드로이드에서는 수동으로 또는 제 3 자 라이브러리를 사용하여 JSON 응답을 구문 분석해야합니다.
당신은 JSON 응답이있는 경우 다음과 같은 다음과 같이
{
"pageInfo": {
"pageName": "abc",
"pagePic": "http://example.com/content.jpg"
}
"posts": [
{
"post_id": "123456789012_123456789012",
"actor_id": "1234567890",
"picOfPersonWhoPosted": "http://example.com/photo.jpg",
"nameOfPersonWhoPosted": "Jane Doe",
"message": "Sounds cool. Can't wait to see it!",
"likesCount": "2",
"comments": [],
"timeOfPost": "1234567890"
}
]
}
그런 다음 위의 응답을 구문 분석 할 수 있습니다. 수입 org.json을 *;
JSONObject obj = new JSONObject(" .... ");
String pageName = obj.getJSONObject("pageInfo").getString("pageName");
JSONArray arr = obj.getJSONArray("posts");
for (int i = 0; i < arr.length(); i++)
{
String post_id = arr.getJSONObject(i).getString("post_id");
......
}
는 또한 GSON library 또는 다른 라이브러리를 사용하여 위의 응답을 구문 분석 할 수 있습니다.
google for android json' 그리고 나서'android run code over time'에 대해 google을 사용하여 2 가지 질문에 대한 답을 찾으십시오. 1 분도 안 남았습니다. –