【发布时间】:2021-11-16 06:30:19
【问题描述】:
我有一个如下的json。
{
"name": "",
"id": "test1",
"properties": {
"name1": [
{
"id": "test2",
},
{
"id": "test3"
}
}
],
"name3": [
{
"id": "test4"
}
],
"name5": [
{
"id": "test7"
}
],
"name7": [
{
"id": "test8"
}
]
}
}
在上面的 JSON 中。我希望提取所有具有“id”的属性的值。所以最后我需要一个 id 值如下的列表。
{"test2", "test3","test4","test7","test8"}
我如何在 C# 中实现这一点。 感谢您的任何建议?
【问题讨论】:
-
你用的是什么 json 库?
-
我尝试通过 JsonConvert 将其转换为动态类型。但我找不到如何处理这种情况?
-
我还希望收到的响应中包含“test1”。如下。 {"test1","test2","test3","test4","test7","test8"}
-
请查看更新。
-
很高兴为您提供帮助。如果 anwser 适合您,请将其标记为已接受。
标签: c# arrays json string object