由于响应,json jarray错误

时间:2014-02-17 04:53:49

标签: c# json json.net

我正在访问的Json不会让我转换为jarray我认为由于开头的响应数据

    {
"response":{
"status":"ok",
"userTier":"approved",
"total":275,
"startIndex":1,
"pageSize":10,
"currentPage":1,
"pages":28,
"orderBy":"newest",
"results":[{
  "id":"guardian-observer-style-guide-b",
  "sectionId":"info",
  "sectionName":"Info",
  "webPublicationDate":"2014-02-14T14:52:00Z",
  "webTitle":"Guardian and Observer style guide: B",
  "webUrl":"http://www.theguardian.com/guardian-observer-style-guide-b",
  "apiUrl":"http://content.guardianapis.com/guardian-observer-style-guide-b"
},{
  "id":"sustainable-business/sustainable-finance-where-next-open-thread",
  "sectionId":"sustainable-business",
  "sectionName":"Guardian Sustainable Business",
  "webPublicationDate":"2014-02-13T13:27:00Z",
  "webTitle":"Where next for sustainable finance? - open thread",
  "webUrl":"http://www.theguardian.com/sustainable-business/sustainable-finance-where-next-open-thread",
  "apiUrl":"http://content.guardianapis.com/sustainable-business/sustainable-finance-where-next-open-thread"
},{
  "id":"media/2014/feb/13/media-briefing-thursday-13-february",
  "sectionId":"media",
  "sectionName":"Media",
  "webPublicationDate":"2014-02-13T08:48:28Z",
  "webTitle":"Today's media stories from the papers",
  "webUrl":"http://www.theguardian.com/media/2014/feb/13/media-briefing-thursday-13-february",
  "apiUrl":"http://content.guardianapis.com/media/2014/feb/13/media-briefing-thursday-13-february"
},{
  "id":"technology/2014/feb/12/bitcoin-exchanges-suspend-conversions-hacker-attack",
  "sectionId":"technology",
  "sectionName":"Technology",
  "webPublicationDate":"2014-02-12T19:38:31Z",
  "webTitle":"Bitcoin exchanges suspend conversions as hacker attack intensifies",
  "webUrl":"http://www.theguardian.com/technology/2014/feb/12/bitcoin-exchanges-suspend-conversions-hacker-attack",
  "apiUrl":"http://content.guardianapis.com/technology/2014/feb/12/bitcoin-exchanges-suspend-conversions-hacker-attack"
},{
  "id":"sustainable-business/sustainable-finance-top-ten-tweeters-twitter",
  "sectionId":"sustainable-business",
  "sectionName":"Guardian Sustainable Business",
  "webPublicationDate":"2014-02-12T12:31:00Z",
  "webTitle":"Twitter list: 10 top sustainable finance tweeters ",
  "webUrl":"http://www.theguardian.com/sustainable-business/sustainable-finance-top-ten-tweeters-twitter",
  "apiUrl":"http://content.guardianapis.com/sustainable-business/sustainable-finance-top-ten-tweeters-twitter"
},{
  "id":"media/2014/feb/11/media-briefing-tuesday-11-february",
  "sectionId":"media",
  "sectionName":"Media",
  "webPublicationDate":"2014-02-11T09:24:13Z",
  "webTitle":"Today's media stories from the papers",
  "webUrl":"http://www.theguardian.com/media/2014/feb/11/media-briefing-tuesday-11-february",
  "apiUrl":"http://content.guardianapis.com/media/2014/feb/11/media-briefing-tuesday-11-february"
},{
  "id":"technology/blog/2014/feb/11/app-purchase-stats-secret",
  "sectionId":"technology",
  "sectionName":"Technology",
  "webPublicationDate":"2014-02-11T07:30:00Z",
  "webTitle":"Boot up: app purchase stats, Secret v anonymity, 4G in China, and more",
  "webUrl":"http://www.theguardian.com/technology/blog/2014/feb/11/app-purchase-stats-secret",
  "apiUrl":"http://content.guardianapis.com/technology/blog/2014/feb/11/app-purchase-stats-secret"
},{
  "id":"technology/2014/feb/10/how-ransomware-turns-your-computer-bitcoin-miner-linkup",
  "sectionId":"technology",
  "sectionName":"Technology",
  "webPublicationDate":"2014-02-10T11:00:26Z",
  "webTitle":"How Ransomware turns your computer into a bitcoin miner",
  "webUrl":"http://www.theguardian.com/technology/2014/feb/10/how-ransomware-turns-your-computer-bitcoin-miner-linkup",
  "apiUrl":"http://content.guardianapis.com/technology/2014/feb/10/how-ransomware-turns-your-computer-bitcoin-miner-linkup"
},{
  "id":"technology/2014/feb/10/cody-wilson-3d-gun-anarchist",
  "sectionId":"technology",
  "sectionName":"Technology",
  "webPublicationDate":"2014-02-10T07:00:00Z",
  "webTitle":"Meet Cody Wilson, creator of the 3D-gun, anarchist, libertarian",
  "webUrl":"http://www.theguardian.com/technology/2014/feb/10/cody-wilson-3d-gun-anarchist",
  "apiUrl":"http://content.guardianapis.com/technology/2014/feb/10/cody-wilson-3d-gun-anarchist"
},{
  "id":"media/2014/feb/07/media-briefing-friday-7-february",
  "sectionId":"media",
  "sectionName":"Media",
  "webPublicationDate":"2014-02-07T08:41:11Z",
  "webTitle":"Today's media stories from the papers",
  "webUrl":"http://www.theguardian.com/media/2014/feb/07/media-briefing-friday-7-february",
  "apiUrl":"http://content.guardianapis.com/media/2014/feb/07/media-briefing-friday-7-february"
}]
}
}

我该如何解决这个问题?我尝试过使用JObject,但只返回数组中的一个对象

由于

1 个答案:

答案 0 :(得分:0)



    JObject json = JObject.Parse (yourstring);
    JArray results = json.SelectToken("response").SelectToken("results");