0

我有这个 Facebook 数据:

    {
  "data": [
    {
      "user": {
        "name": "James Pearce", 
        "id": "738229837"
      }, 
      "score": 20, 
      "application": {
        "name": "Bubble Safari", 
        "namespace": "bubblesafari", 
        "id": "164731003644283"
      }
    },
    ...

我想将这些数据解析为字符串。我从结果对象的这个监听器中获取这些数据:

FBRequestConnection.StartWithGraphPath(AppId+"/scores?fields=score,user",null,"GET", 
(FBRequestConnection connection, NSObject result, NSError err) => {
    if (err != null)
        ShowMessage("Error", string.Format ("Error:\nDomain: {0}\nCode: {1}\nDescription: {2}", err.Domain, (FBErrorCode)err.Code, err.Description));
});

如何将这些数据解析为字符串?

4

1 回答 1

3

这是 Json 格式的数据。使用JSON.Net组件解析数据,然后您可以访问各个成员。

string data = ... whatever the FB response is ...
var parsed = JObject.Parse (data);

var user = data["data"]["user"];
var name = user["name"];
var score = data["data"]["score"];
于 2013-09-28T23:14:12.530 回答