以下のJSONを解析し、すべての値をscreenshot.thumbnailUrlにしたいと思います。しかし、私の制約は以下の通りです。キーを知らずにjsonを読む#
すべてのノードがスクリーンショットを持っているわけではありません。この例では、「天気」と「エンティティ」だけがそれを持っています。
ノード名がわかりません。この例では、「天気」または「エンティティ」という名前のノードがあることはわかりませんでした。これらのノードは、jsonを取得するために作成したクエリに基づいて自動的に生成されます。
スクリーンショットが存在する可能性がある場所は2つあります。 (1)ルートオブジェクトの子に。 weather.screenshot(2)rootobjectの子のすべての値。 entities.value [0] .screenshotを、entities.value [1] .screenshotなど
{ "_type": "SearchResponse", "queryContext": {}, "webPages": {}, "entities": {
"queryScenario": "DominantEntity",
"value": [
{
"_type": "Place",
"id": "https://www.someapi.com/api/v6/#Entities.0",
"screenshot": {
"thumbnailUrl": "http://Screenshot_URL_I_Want",
"width": 285
},
"name": "Seattle",
"entityPresentationInfo": {},
"bingId": "5fbba6b8-85e1-4d41-9444-d9055436e473",
"boundingBox": [],
"weather": {},
"timeZone": "Pacific Standard Time"
}
] }, "images": {}, "weather": {
"id": "https://www.someapi.com/api/v6/#Weather",
"screenshot": {
"thumbnailUrl": "http://Screenshot_URL_I_Want",
"width": 285
},
"location": {},
"currentWeather": {},
"dailyForecast": [] }, "rankingResponse": {} }
デシリアライズ用にjson .netを使用できますか? – StellaMaris