【发布时间】:2020-07-07 14:17:42
【问题描述】:
我从多个 Web 服务收到复杂的 JSON 响应。我需要使用 python 获取各个级别的所有键。要使用 JSON_NORMALISE 我需要知道键名。由于我收到多个回复,因此无法提供密钥名称。如果我在外层进行标准化,则较低级别的 json 不会转换为字典。还是json格式的。
{'Id': 123,
'oldnumber': 1,
'new number': 8,
'version': 1,
'newversion': 1,
'personList':[{
'id':1,
'name': xyz,
'marks':[{'phy':90,
'che':80
}
{'bot':90,
'zoo':80
},
{'phy':60,
'che':80
}
{'bot':20,
'zoo':80
}
]}
],
'anotherList':[{
'id':1,
'data': xyz,
'some':[{'not':90,
'dot':80
}
{'cot':90,
'pot':80
},
{'ans':60,
'dog':80
}
{'cat':20,
'mat':80
}
]}
]
}
如何从响应中获得的 JSON 中读取所有键名?
【问题讨论】:
标签: json python-3.x pandas rest web-services