我有一个关于生活彩带在每日运动平台上的应用。Dailymotion有一个websdk (在json中)。我不知道如何在android中使用json。我想知道如果dailymotion是开着还是关着的话,怎么做呢?我要我们检查json所有的x分钟。
JSON:https://api.dailymotion.com/video/x3p6d9r?fields=onair
请给我任何建议。
发布于 2016-08-30 11:44:07
基本上,在android中,您必须手动或使用第三方库解析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"
}
]
}然后您可以解析上面的响应如下: import 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图书馆或其他库解析上述响应。
https://stackoverflow.com/questions/39226456
复制相似问题