We follow RFC 9535 strictly and test against the JSONPath Compliance Test Suite.
Table of Contents
Install Python JSONPath RFC 9535 using pip:
python -m pip install jsonpath-rfc9535
Or uv:
uv add jsonpath-rfc9535
Or Pipenv:
pipenv install -u jsonpath-rfc9535
- Documentation: https://jg-rp.github.io/python-jsonpath-rfc9535/
- Change log: https://github.com/jg-rp/python-jsonpath-rfc9535/blob/main/CHANGELOG.md
- PyPi: https://pypi.org/project/jsonpath-rfc9535
- Source code: https://github.com/jg-rp/python-jsonpath-rfc9535
- Issue tracker: https://github.com/jg-rp/python-jsonpath-rfc9535/issues
import jsonpath_rfc9535 as jsonpath
expr = "$.users[?@.status == 'pending'].name"
data: dict[str, object] = {
"users": [
{"id": "usr_101", "name": "Alice", "status": "pending"},
{"id": "usr_102", "name": "Bob", "status": "active"},
{"id": "usr_103", "name": "Charlie", "status": "pending"},
],
}
nodes = jsonpath.find(expr, data)
print(nodes.values()) # ['Alice', 'Charlie']
print(nodes.locations()) # [('users', 0, 'name'), ('users', 2, 'name')]
print(nodes.paths()) # ["$['users'][0]['name']", "$['users'][2]['name']"]- Python JSONPath - Another Python package implementing JSONPath, but with additional features and customization options.
- JSON P3 - RFC 9535 implemented in TypeScript.
python-jsonpath-rfc9535 is distributed under the terms of the MIT license.