Registry / serialization / python-jsonpath

python-jsonpath

JSON →
library2.2.1pypypi✓ verified 25d ago

Python JSONPath is a flexible engine for processing JSONPath, JSON Pointer, and JSON Patch expressions. It aims to be compliant with RFC 9535 for JSONPath, RFC 6901 for JSON Pointer, and RFC 6902 for JSON Patch. The library is currently at version 2.0.2 and receives regular updates and maintenance, often with a few releases per year.

pip install python-jsonpath
INSTALL
IMPORT
SIG · PYTHON-JSONPATH
P
python-jsonpath
serializationpythonv2.2.1
Install
1.6s avg
Import
618ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.1 · 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.628s · 18.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.608s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

jsonpath
import jsonpath
from jsonpath_ng import parse
There are multiple Python JSONPath implementations; 'jsonpath_ng' is a different library.

This quickstart demonstrates basic JSONPath queries using `findall()` and `compile()` to extract data from a sample JSON structure. It shows how to select elements, filter by conditions, and compile paths for efficiency.

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}, {"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99} ], "bicycle": {"color": "red", "price": 19.95} }, "expensive": 10 } # Find the titles of all books book_titles = jsonpath.findall("$.store.book[*].title", data) print(f"Book Titles: {book_titles}") # Find all books cheaper than $10 cheap_books = jsonpath.findall("$.store.book[?(@.price < 10)].title", data) print(f"Cheap Book Titles: {cheap_books}") # Compile a JSONPath expression for repeated use compiled_path = jsonpath.compile("$.store.book[?(@.category == 'fiction')].author") fiction_authors = compiled_path.findall(data) print(f"Fiction Authors: {fiction_authors}")
Debug
Known issues
breakingVersion 2.0.0 introduced significant breaking changes to JSONPath syntax in the default configuration. Unquoted property names are no longer treated as literals in bracket notation. It also introduced a new 'strict mode' enforcing full RFC 9535 compliance.
fix
Review JSONPath queries using unquoted bracket notation (e.g., `$.obj[prop]`) and update them to use quoted strings (e.g., `$.obj['prop']`) or dot notation (`$.obj.prop`). If strict RFC 9535 compliance is desired, enable `strict=True` in query functions like `findall()` or `compile()`.
affects: >=2.0.0
breakingJSON Pointers with negative indices are no longer permitted by default, aligning with RFC 6901. Attempting to use a negative index will raise a `JSONPointerIndexError`.
fix
If negative indices are required for JSON Pointers, set `JSONPointer.min_int_index` to a suitably negative integer to override the default behavior.
affects: >=2.0.1
breakingSupport for Python 3.7 was dropped.
fix
Upgrade to Python 3.8 or newer.
affects: >=1.2.2
gotchaParsing of non-standard JSONPath regular expression literals containing an escaped solidus (`/`) was incorrect prior to v2.0.2, affecting queries using the regex operator `=~`.
fix
Upgrade to version 2.0.2 or higher to ensure correct parsing of such regex literals.
affects: <2.0.2
gotchaThe non-standard JSON Patch operation `addap` (add-after-property) was behaving incorrectly, like `addne` (add-if-not-exists), in versions prior to 1.3.1. Also, JSON Patch operations on mappings with integer-like targets could behave unexpectedly.
fix
Upgrade to version 1.3.1 or higher for corrected behavior of `addap` and improved handling of integer-like targets in JSON Patch operations.
affects: <1.3.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jsonpath'
The 'jsonpath' module is not installed in the Python environment.
fix
Install the module using 'pip install python-jsonpath'.
AttributeError: module 'jsonpath' has no attribute 'jsonpath'
Incorrect import statement; the 'jsonpath' module does not have a 'jsonpath' attribute.
fix
Use 'import jsonpath' and access functions like 'jsonpath.findall()'.
jsonpath_ng.lexer.JsonPathLexerError: Error on line 1, col 8: Unexpected character: /
The JSONPath expression contains an unexpected character, such as a forward slash, which is not handled by the parser.
fix
Ensure the JSONPath expression is correctly formatted and does not include unsupported characters.
jsonpath_ng.exceptions.JsonPathParserError: Error on line 1, col 8: Unexpected character: /
The JSONPath expression includes a forward slash, which is not recognized by the parser.
fix
Replace the forward slash with a valid character or adjust the JSONPath expression to avoid using unsupported characters.
jsonpath_ng.exceptions.JsonPathParserError: Error on line 1, col 8: Unexpected character: ?
The JSONPath expression contains a question mark, which is not correctly used in the context.
fix
Ensure the question mark is used appropriately in filter expressions, such as '[?(@.field == value)]'.
Upgrade
Version history
2.2.1latest on PyPI · released Jul 7, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Resources
python-jsonpath — pip install python-jsonpath · libregistry