[英]how to read nested json objects in c#
我有json字符串
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 78,
"max_score": 1.5,
"hits": [{
"_index": "S3",
"_type": "se",
"_id": "00CD03",
"_score": 1.5,
"contact": {
"defaultAddress": {
"addressLine1": "AAAAAAAAAAAAAAA",
"addressLine2": null,
"addressCode": null,
"geoLocation": {
"lon": "14.1514",
"lat": "16.7555"
},
},
"defaultEmail": "aaaa.bbbb@gmail.in",
"defaultPhoneNumber": "080 1140 637",
}
}, {
"_index": "S3",
"_type": "se",
"_id": "00C3D0-01260-3",
"_score": 1.5,
"contact": {
"defaultAddress": {
"addressLine1": "bbbbbbbbbb 1",
"addressLine2": "ggggggggg",
"addressCode": null,
"geoLocation": {
"lon": "97.1511101",
"lat": "15.7888899"
},
},
"defaultEmail": "kkkkk@yahoo.de",
"defaultPhoneNumber": "0909 140 637",
}
}
]
}
}
需要遍歷 json 並在 C# 中創建一個列表詳細信息。 尋求幫助
@NLSrini
您可以使用金塊包“ Newtonsoft.Json ”。 然后你可以創建一個代表你的 JSON 結構的類 Object 並反序列化你可以使用: JsonConvert.DeserializeObject<YourClass>(json);
您可以在此處查看更多示例: https : //www.newtonsoft.com/json/help/html/SerializingJSON.htm
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.