【发布时间】:2016-10-20 15:24:08
【问题描述】:
我希望解析一个动态生成的、没有明确结构的 JSON 文件。
[
{
"children": [
{
"children": [
{
"children": [],
"text": "Child node 2.txt",
"isFolder": false,
"id": "1childnode2.txt",
"itsPath": "C:\\Users\\pandyapa\\Root node\\Child node 2.txt",
"type": "itsfile"
}
],
"text": "Child node 1.txt",
"isFolder": false,
"id": "0childnode1.txt",
"itsPath": "C:\\Users\\pandyapa\\Root node\\Child node 1.txt",
"type": "itsfile"
},
{
"children": [],
"text": "Child node 2.txt",
"isFolder": false,
"id": "1childnode2.txt",
"itsPath": "C:\\Users\\pandyapa\\Root node\\Child node 2.txt",
"type": "itsfile"
},
{
"children": [],
"text": "Child node 3.txt",
"isFolder": false,
"id": "2childnode3.txt",
"itsPath": "C:\\Users\\pandyapa\\Root node\\Child node 3.txt",
"type": "itsfile"
}
],
"text": "Root node",
"isFolder": true,
"id": "3rootnode",
"itsPath": "C:\\Users\\pandyapa\\Root node",
"type": "default"
}
]
此 JSON 可以有任何嵌套的子级。我希望解析每个 JSON 对象,比较它的“id”键并检索“它的路径”值。 我试过但没有成功。非常感谢任何帮助。
【问题讨论】:
-
阅读How to Ask,展示你的尝试以及它们是如何失败的。
-
试试这个,@Parth:stackoverflow.com/questions/17038810/…