大家好,我正在为此工作几个小时,但似乎我无法完成这项工作。
我有这个json结构:
{
"1": {
"name": "foo",
"color": "black",
"children": ["2", "3"]
},
"2": {
"name": "foo2",
"color": "green",
"children": []
},
"3": {
"name": "foo3",
"color": "yellow",
"children": ["4"]
},
"4": {
"name": "foo4",
"color": "purple",
"children": []
}
}
我想使用python字典在下一个json结构中转换它:
{
"foo":{
"color":"black",
"children":{
"foo2":{
"color":"green",
"children":{}
},
"foo3":{
"color":"yellow",
"children":{
"foo4":{
"color":"purple",
"children":{}
}
}
}
}
}
}
有人能帮助我吗?