谢谢阅读!
我正在尝试开发一个 android 应用程序,但我被困在如何获取用户的“喜欢”上。我需要的只是每个“名称”键的值。在这里,他们将是“周杰伦”、“陈奕迅”和“Facebook 开发者”。下面是 JSON 文本
{
"languages": [
{
"id": "111735208843636",
"name": "Chinese"
},
{
"id": "106059522759137",
"name": "English"
}
],
"id": "100005065353669",
"likes": {
"data": [
{
"category": "Musician/band",
"name": "Jay Chou",
"id": "109155665769390",
"created_time": "2013-06-11T18:54:44+0000"
},
{
"category": "Musician/band",
"name": "Eason Chan",
"id": "105468519487919",
"created_time": "2013-06-05T20:33:26+0000"
},
{
"category": "Product/service",
"name": "Facebook Developers",
"id": "19292868552",
"created_time": "2013-05-31T01:35:17+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/100005065353669/likes? limit=5000&offset=5000&__after_id=19292868552"
}
}
}
这段代码用于获取用户的“语言”,对我来说效果很好。
JSONArray languages = (JSONArray)user.getProperty("languages");
if (languages.length() > 0) {
ArrayList<String> languageNames = new ArrayList<String> ();
for (int i=0; i < languages.length(); i++) {
JSONObject language = languages.optJSONObject(i);
languageNames.add(language.optString("name"));
}
userInfo.append(String.format("Languages: %s\n\n", languageNames.toString()));
}
user
来自函数参数private String buildUserInfoDisplay(GraphUser user)
,userinfo
来自StringBuilder userInfo = new StringBuilder("");
谁能帮我?真的很感激!