[英]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.