加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_json.py 2.90 KB
一键复制 编辑 原始数据 按行查看 历史
JIYANG-PLUS 提交于 2021-08-21 00:54 . 0.2.5.4
import UniversalParser as UP
json_data = """
{
"message": null,
"value": [
{
"naturalid": null,
"name": "龚亮",
"phone": "18693517091",
"djxh": "10216223000000009540",
"nsrmc": null,
"nsrsbh": null,
"isBinding": "Y",
"roleType": "5",
"sqlxDm": null,
"sqztDm": null,
"lcslid": "",
"sqczsfzjhm": null,
"bsrysfzjhm": "62230119910409877X",
"realName": true
},
{
"naturalid": null,
"name": "龚亮",
"phone": "18693517091",
"djxh": "10216223000000009540",
"nsrmc": null,
"nsrsbh": null,
"isBinding": "Y",
"roleType": "6",
"sqlxDm": null,
"sqztDm": null,
"lcslid": "",
"sqczsfzjhm": null,
"bsrysfzjhm": "62230119910409877X",
"realName": true
},
{
"naturalid": null,
"name": "龚亮",
"phone": "18693517091",
"djxh": "10216223000000009540",
"nsrmc": null,
"nsrsbh": null,
"isBinding": "Y",
"roleType": "9",
"sqlxDm": null,
"sqztDm": null,
"lcslid": "",
"sqczsfzjhm": null,
"bsrysfzjhm": "62230119910409877X",
"realName": true
},
{
"naturalid": null,
"name": "龚亮",
"phone": "18693517091",
"djxh": "10216223000000009540",
"nsrmc": null,
"nsrsbh": null,
"isBinding": "Y",
"roleType": "10",
"sqlxDm": null,
"sqztDm": null,
"lcslid": "",
"sqczsfzjhm": null,
"bsrysfzjhm": "62230119910409877X",
"realName": true
},
{
"naturalid": null,
"name": "李春兰",
"phone": "13689353360",
"djxh": "10216223000000009540",
"nsrmc": null,
"nsrsbh": null,
"isBinding": "Y",
"roleType": "11",
"sqlxDm": null,
"sqztDm": null,
"lcslid": "",
"sqczsfzjhm": null,
"bsrysfzjhm": "622326197701140022",
"realName": true
}
],
"success": true,
"msgCode": null,
"resultMap": {},
"msgParams": null,
"jylsh": "e087e96026ce4079979f0cd7d7db26d6"
}
"""
jsonManager = UP.parse_json(json_data, real_cdata_key='string')
_text = jsonManager.find_text
status = jsonManager.find_nodes_by_tag('success', one_=True)
print(_text(status)) # True
print(status.string) # True
values = jsonManager.find_nodes_by_tag('value')
print(values[-1].name) # 李春兰
print(jsonManager.document.root.jylsh) # e087e96026ce4079979f0cd7d7db26d6
jsonManager.save_as_xml()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化