Json嵌套参数

我正在使用来自Json对象的数据来填充列表视图。 该对象具有以下参数:

"id": "339150749455906", "posts": { "data": [ { "id": "339150749455906_545370565500589", "from": { "category": "Food/beverages", "name": "Pepsi", "id": "339150749455906" }, "story": "Pepsi updated their cover photo.", "picture": "http://sofzh.miximages.com/c%23/942740_545370555500590_46289134_s.jpg", "link": "http://www.facebook.com/photo.php?fbid=545370555500590&set=a.365573920146922.72816.339150749455906&type=1&relevant_count=1", "icon": "http://sofzh.miximages.com/c%23/StEh3RhPvjk.gif", "actions": [ { "name": "Comment", "link": "http://www.facebook.com/339150749455906/posts/545370565500589" }, { "name": "Like", "link": "http://www.facebook.com/339150749455906/posts/545370565500589" } ], 

我想访问参数/键“actions”中的链接。 到目前为止我正在使用:

 foreach (var post in postsTaskResult.posts.data) { link = new Uri(string.Format("{0}", (string)post["link"])); } 

但是,这只会带来“数据”中的链接。 如何访问其他“链接”?

试试这个。

 var actionLinks = new List(); var actions = post["actions"] as JArray; // if this works then all is well foreach(var item in actions) { actionLinks.Add((string)item["link"]); } 

我想你也可以使用一些花哨的Linq

 var actionLinks = ((JArray)post["actions"]) .Children() .Select(a => (string)a["link"]) .ToList(); 

非常未经测试。 请告诉我。