Newtonsoft JSON.net を使用すると、次の JToken 結果が得られます。
"60": {
"maps": false,
"real_time": false,
"video_pack_results": {},
"indented": 0,
"blog_posts": false,
"description": "A LONDON household is celebrating a U-turn by an insurance company that means the occupants no longer have to foot half a pounds 25000 bill for ...",
"base_url": "www.independent.co.uk",
"place_pack": {},
"dirty_url": "/url?q=http://www.independent.co.uk/news/business/subsidence-leads-to-an-insurance-fallout-transfer-of-property-freehold-leaves-flat-owners-without-full-cover-1481999.html&sa=U&ei=qiPFUIv2J4WJiwLc3ICQAQ&ved=0CKMBEBYwJzgU&usg=AFQjCNFbJ0NSAqXOnBdAViKZXQidPK1vEg",
"video": false,
"href": "http://www.independent.co.uk/news/business/subsidence-leads-to-an-insurance-fallout-transfer-of-property-freehold-leaves-flat-owners-without-full-cover-1481999.html",
"title": "Subsidence leads to an insurance fall-out: Transfer of property ...",
"news": false,
"shopping": false,
"micro_format": false,
"image": false,
"place_details": {},
"image_pack_results": [],
"url": "http://www.independent.co.uk/news/business/subsidence-leads-to-an-insurance-fallout-transfer-of-property-freehold-leaves-flat-owners-without-full-cover-1481999.html",
"brand_pack_results": {},
"local_pack": {},
"page": 7,
"base_domain": "independent.co.uk"
}
次の方法を使用してJSON.netから解析するときに、値「60」を取得しようとしています:
var keyValue = JsonConvert.DeserializeObject<KeyValuePair<string, string>>(jToken.ToString());
私が最初に遭遇したエラーは、最初に JToken から生の JSON 文字列に追加した最初のコンテンツを囲む "{" "}" タグの欠落でした。この結果は、空の KeyValuePair タイプでした。
Key プロパティと Value プロパティを分離するために、上記の形式で JToken を解析する方法を知っている人はいますか?