Jsonpath
安装:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jsonpath
使用:jsonpath 只能解析本地文件,跟xpath不一样
obj=json.load(open(‘json文件’,‘r’, encoding=‘utf-8’)) json.load(是文件,不是字符串)
ret=jsonpath.jsonpath(obj,‘jsonpath语法’)
{
"store": {
"book":[
{
"category": "修真",
"author": "六道",
"title": "坏蛋是怎样炼成的",
"price": 8.95
},
{
"category": "修真",
"author": "天蚕土豆",
"title": "斗破苍穹",
"price": 12.99
},
{
"category": "修真",
"author": "唐家三少",
"title": "斗罗大陆",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "修真",
"author": "南派三叔",
"title": "皇辰变",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "黑色",
"price": 19.95
}
}
}