Another JSONPath implementation for Python.
Project description
Python JSONPath
A flexible JSONPath engine for Python.
Table of Contents
Install
Install Python JSONPath using pip:
pip install python-jsonpath
Or Pipenv:
pipenv install -u python-jsonpath
Or from conda-forge:
conda install -c conda-forge python-jsonpath
Links
- Documentation: https://jg-rp.github.io/python-jsonpath/.
- JSONPath Syntax: https://jg-rp.github.io/python-jsonpath/syntax/
- Change log: https://github.com/jg-rp/python-jsonpath/blob/main/CHANGELOG.md
- PyPi: https://pypi.org/project/python-jsonpath
- Source code: https://github.com/jg-rp/python-jsonpath
- Issue tracker: https://github.com/jg-rp/python-jsonpath/issues
Examples
JSONPath
import jsonpath
data = {
"users": [
{
"name": "Sue",
"score": 100,
},
{
"name": "John",
"score": 86,
},
{
"name": "Sally",
"score": 84,
},
{
"name": "Jane",
"score": 55,
},
]
}
user_names = jsonpath.findall("$.users[?@.score < 100].name", data)
print(user_names) # ['John', 'Sally', 'Jane']
JSON Pointer
Since version 0.8.0, we also include an RFC 6901 compliant implementation of JSON Pointer.
from jsonpath import pointer
data = {
"users": [
{
"name": "Sue",
"score": 100,
},
{
"name": "John",
"score": 86,
},
{
"name": "Sally",
"score": 84,
},
{
"name": "Jane",
"score": 55,
},
]
}
sue_score = pointer.resolve("/users/0/score", data)
print(sue_score) # 100
jane_score = pointer.resolve(["users", 3, "score"], data)
print(jane_score) # 55
License
python-jsonpath is distributed under the terms of the MIT license.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_jsonpath-0.8.1.tar.gz.
File metadata
- Download URL: python_jsonpath-0.8.1.tar.gz
- Upload date:
- Size: 31.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7c4a184e265508dbc3ec85596bd90e52a29b4fe53acdde1c13477d4ded7ad03
|
|
| MD5 |
c81b9dff79d49c36d1a7eee53119232d
|
|
| BLAKE2b-256 |
d2dbce4651fe30d3a41e3b9e3b4c43af2d98814014e0b0f55d853154680c6037
|
File details
Details for the file python_jsonpath-0.8.1-py3-none-any.whl.
File metadata
- Download URL: python_jsonpath-0.8.1-py3-none-any.whl
- Upload date:
- Size: 40.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c1cbddcfd0a76398dc1c7991dfb5928ddc26a5c78fbd15c53bc0fcfa80f8751
|
|
| MD5 |
d2735aa84d161536983156dae4216d2e
|
|
| BLAKE2b-256 |
dd82ac5971aaad4843597c29d74e52b5e91ad547e26a30a4ae3b64f837caaae7
|