从json文件中获取节点值

时间:2013-12-04 19:07:30

标签: json facebook linq

我正在开发一个facebook graph api项目,并拥有这个json文件:

     {
  "data": [
    {
      "id": "407356746023254_569534706472123", 
      "from": {
        "category": "Furniture", 
        "name": "`enter code here`", 
        "id": "407356746023254"
      }, 
      "message": "message", 

      "actions": [
        {
          "name": "Comment", 
          "link": "https://www.facebook.com/407356746023254/posts/569534706472123"
        }, 
        {
          "name": "Like", 
          "link": "https://www.facebook.com/407356746023254/posts/569534706472123"
        }
      ], 
      "privacy": {
        "value": ""
      }, 
      "type": "photo", 
      "status_type": "added_photos", 
      "object_id": "569534676472126", 
      "created_time": "2013-12-03T22:54:45+0000", 
      "updated_time": "2013-12-04T15:29:03+0000", 
      "shares": {
        "count": 1
      },

我正在使用Newtonsoft.Json.Linq解析此文件

我的代码:

 For i = 0 To o("data").Count - 1
         Dim o As JObject = JObject.Parse(data)
    Response.Write(o("data")(i)("shares"))
next

代码结果为{" count":1}

我想只获得价值" 1"来自

"shares": {
        "count": 1
      },

但我不能

我想我在某种程度上错过了这个概念。任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

For i = 0 To o("data").Count - 1
    Dim o As JObject = JObject.Parse(data)
    Response.Write(o("data")(i)("shares")("count"))
next

这可能对你有帮助...... :);):P