# xjson
xjson 是一个能让你用xpath 语法来解析的json的工具
##Overview
在处理json的时候,如果json 列表有很多元素的话,需要一个个迭代去处理。然而在xpath 却不是这样的,xpath 可以把路径下的都提取出来,这样就能把提取 变成一行,方便写在配置文件中。 xjson 做的就是这么一件事。让你能够以xpath的形式解析json。
{
"success":true,
"message":"操作成功!",
"result":[
{
"firstCategoryList":[
{
"name":"工具",
"id":"2"
}
],
"secondCategoryList":[
{
"name":"钻削类电动工具",
"id":"142",
"list":[
{
"name":"手电钻",
"id":"925"
},
{
"name":"磁座钻",
"id":"928"
}
]
},
{
"name":"磨削类电动工具",
"id":"143",
"list":[
{
"name":"角向磨光机",
"id":"936"
},
{
"name":"磨具电磨",
"id":"937"
}
]
}
]
}
]
}
如果用json,需要把三级分类提取出来的话,你需要写成
for result in json_content["result"]:
for second_category in result["secondCategoryList"]:
for third_category in second_category["list"]:
print third_category["name"]
不仅混乱,而且需要时刻注意各层嵌套之间的关系,而在 xjson 中,你只需要按照层次关系写成
result/secondCategoryList/list/name
就可以把三级分类全部提取出来了。 而且这样做的话,放在配置文件中,通过配置来提取json是非常方便的。
Requirements
python2.7
Metadata
Release files for xjson 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xjson-0.1.5.zip | 5.8 kB | Without provenance | Details |
Release files / xjson-0.1.5.zip
| Download URL | xjson-0.1.5.zip |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78ce0d8a7091d811e7a4e9b4d09a60275f7ad98eb601c53b26bfe3d8476939db
|
|
BLAKE2b-256 checksum How to use checksums |
a053fe4b774126dec1b6ac212bc64db19d05c7ce476d71e8d0c2166a878b6bc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for xjson 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.