如何在android中使用json获取facebook个人资料信息

时间:2014-02-09 11:16:38

标签: android json facebook facebook-graph-api

我想从这种类型的json获得学校名称:

"username": "blah",
       "education": [
          {
             "school": {
                "id": "[removed]",
                "name": "[removed]"
             },
             "year": {
                "id": "[removed]",
                "name": "[removed]"
             },
             "type": "High School"
          },
          {
             "school": {
                "id": "[removed]",
                "name": "[removed]"
             },
             "year": {
                "id": "[removed]",
                "name": "[removed]"
             },
             "type": "College"
          }
       ]

这是我的代码:

JSONObject obj=null;
URL img_url;

String jsonUser = facebook.request("me");
obj=Util.parseJson(jsonUser);
String id=obj.optString("id");
String name=obj.optString("name");

我应该写什么代码来获得教育领域的学校名称?

2 个答案:

答案 0 :(得分:1)

    Facebook fb = new Facebook(API_KEY);// ... login user here ...JSONObject me = new JSONObject(fb.request("me")); String id = me.getString("id");

答案 1 :(得分:0)

你可以尝试

var schoolname =  yourobject.education.school.name