A selector expression for extracting data from JSON.
Project description
A selector expression for extracting data from JSON.
Quickstarts
Installation
Install the stable version from PYPI.
pip install jsonpath-extractor
Or install the latest version from Github.
pip install git+https://github.com/linw1995/jsonpath.git@master
Usage
import json
from jsonpath import parse, Root, Contains, Self
data = json.loads(
"""
{
"goods": [
{"price": 100, "category": "Comic book"},
{"price": 200, "category": "magazine"},
{"price": 200, "no category": ""}
],
"targetCategory": "book"
}
"""
)
expect = [{"price": 100, "category": "Comic book"}]
assert parse("$.goods[contains(@.category, $.targetCategory)]").find(data) == expect
assert (
Root()
.Name("goods")
.Array(Contains(Self().Name("category"), Root().Name("targetCategory")))
.find(data)
== expect
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for jsonpath_extractor-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 031f42957accc2ff09cd07cb4502bfdde7ebed309d7ff41b2accf3c2ad0fc913 |
|
MD5 | 700af58e473c515122fc28299135cf37 |
|
BLAKE2b-256 | 5ec9f1af18db3b5f88dde10b3a43f94449d3bda8d1f7073d23f671b1eb1123de |