python递归遍历Json(容易理解且最好⽤)import json
#json⽂件发送形式
SendRegisterVerificationCodejson_txt = """
{
"menus": [{
"key": "测试1",
"type": "Channel",
"owner": "",
"title": "标题1",
"fav": "false",
"lineSelect": "false",
"chartSelect": "false"
}, {
"key": "测试2",
"type": "Channel",
"owner": "",
"title": "标题2",
"fav": "false",
"lineSelect": "false",
"chartSelect": "false"
骰子随机数字生成}, {
"key": "测试3",
python解析json文件"type": "Channel",
"owner": "",
"index": "1",
"title": "标题3",
"fav": "false",
"lineSelect": "false",
"chartSelect": "false"
}]
}
"""
date_json = json.loads(SendRegisterVerificationCodejson_txt)
def print_keyvalue_all(input_json):scala语言spark
if isinstance(input_json,dict):
for key in input_json.keys():
对象的实例化是什么意思
key_value = (key)
fadetop设置
if isinstance(key_value,dict):
print_keyvalue_all(key_value)
elif isinstance(key_value,list):
for json_array in key_value:
print_keyvalue_all(json_array)
else:
print (str(key)+ " = " +str(key_value))
windsnselif isinstance(input_json,list):
for input_json_array in input_json:
print_keyvalue_all(input_json_array)
print_keyvalue_all(date_json)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。