【发布时间】:2014-09-14 00:47:01
【问题描述】:
假设你有一个这样的字符串:
{
"inventory1": {
"confirmed": 1,
"items": [{
"id": "42",
"ammount": "2"
}, {
"id": "41",
"ammount": "3"
}]
},
"inventory2": {
"confirmed": 1,
"items": [{
"id": "43",
"ammount": "1"
}, {
"id": "41",
"ammount": "2"
}]
}
}
如何将inventory1 中每个项目的ID 放入字符串列表中?
【问题讨论】:
-
使用 POCO 映射并对其进行反序列化,或者使用 JObject/JArray,甚至是
dynamic- 其中有 no shortage of examples。在理解了第一个“我如何访问”之后,提取本身就相当简单了,比如使用 LINQ 甚至手动循环。无论如何,没有代码/尝试->没有问题/问题,只有一个任务。请查阅有关该主题的文档和以前的问题。
标签: c# json json.net deserialization