Registry / serialization / jsonpath-python

jsonpath-python

JSON →
library1.1.6pypypi✓ verified 25d ago

jsonpath-python is a lightweight and powerful implementation of the JSONPath specification for Python, enabling users to extract data from JSON objects using XPath-like expressions. It is actively maintained, with version 1.1.5 being the current release, and follows a moderate release cadence addressing fixes, performance, and security.

pip install jsonpath-python
INSTALL
IMPORT
SIG · JSONPATH-PYTHON
J
jsonpath-python
serializationpythonv1.1.6
Install
1.6s avg
Import
123ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.128s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.118s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JSONPath
from jsonpath import JSONPath

Initializes a JSONPath object with an expression and uses its `parse` method to extract matching values from a dictionary. The `parse` method returns a list of all matched items. Other methods like `match` (returns first match) and `findall` (returns generator) are also available.

from jsonpath import JSONPath data = { "store": { "book": [ {"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95}, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99} ], "bicycle": {"color": "red", "price": 19.95} } } # Find all authors of books path_expression = '$..book[*].author' path = JSONPath(path_expression) authors = path.parse(data) print(f"Authors: {authors}") # Find all prices all_prices = JSONPath('$..price').parse(data) print(f"All prices: {all_prices}")
Debug
Known issues
breakingA critical security fix in version 1.1.5 (released 2026-03-17) prevents Remote Code Execution (RCE) via `eval()` in filter expressions. Prior versions (<=1.1.4) were vulnerable if untrusted JSONPath expressions containing filter clauses were processed. Update immediately to prevent potential security breaches.
fix
Upgrade to version 1.1.5 or newer: `pip install --upgrade jsonpath-python`.
affects: <=1.1.4
breakingAs of version 1.1.0, sorting arrays with mixed data types (e.g., numbers and strings) in filter expressions will now raise a `JSONPathTypeError`. Previously, this behavior was undefined and could lead to inconsistent or erroneous results without explicit error notification.
fix
Ensure that arrays intended for sorting in filter expressions contain elements of a consistent, comparable type. Handle `JSONPathTypeError` if mixed-type data is expected, or pre-process data to normalize types before applying JSONPath expressions.
affects: <1.1.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jsonpath'
The 'jsonpath-python' library has not been installed in your Python environment, or there's an issue with your Python path.
fix
Install the library using pip: `pip install jsonpath-python`
AttributeError: module 'jsonpath' has no attribute 'jsonpath'
This error typically occurs when a different Python package named 'jsonpath' is installed (e.g., an older version, or a different library like `jsonpath_rw` or `jsonpath_ng` that doesn't expose `jsonpath.jsonpath()` directly) or if there's a local file named `jsonpath.py` shadowing the installed package.
fix
Ensure `jsonpath-python` (the specified library) is correctly installed, and that there are no conflicting local files or other `jsonpath` packages. You can verify the installed package's location with `python -c "import jsonpath; print(jsonpath.__file__)"`. If a different library is intended, adjust the import statement, for example, `from jsonpath_ng import jsonpath, parse` for `jsonpath-ng`.
ValueError: Invalid JSON Path: <your_expression>
The JSONPath expression provided is syntactically incorrect or does not conform to the `jsonpath-python` library's interpretation of the JSONPath specification.
fix
Review your JSONPath expression for syntax errors. Common issues include incorrect use of operators, unquoted string literals where required, or invalid filter conditions. Refer to the `jsonpath-python` documentation for the supported syntax.
AttributeError: module 'jsonpath_python' has no attribute 'JsonPath'
The main `JsonPath` class is located within the `jsonpath` submodule of `jsonpath_python`, not directly under the top-level package.
fix
from jsonpath_python.jsonpath import JsonPath
AttributeError: 'JsonPath' object has no attribute 'find'
The `jsonpath-python` library uses the method `parse()` to evaluate the JSONPath expression against data, whereas other JSONPath libraries might use a `find()` method.
fix
jsonpath_expr = JsonPath(expression)
result = jsonpath_expr.parse(data)
Upgrade
Version history
1.1.6latest on PyPI · released May 7, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Resources