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-jsonpathVerified import paths — ran on the pinned version, not inferred.
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.
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()`.
If negative indices are required for JSON Pointers, set `JSONPointer.min_int_index` to a suitably negative integer to override the default behavior.
Upgrade to Python 3.8 or newer.
Upgrade to version 2.0.2 or higher to ensure correct parsing of such regex literals.
Upgrade to version 1.3.1 or higher for corrected behavior of `addap` and improved handling of integer-like targets in JSON Patch operations.
Install the module using 'pip install python-jsonpath'.
Use 'import jsonpath' and access functions like 'jsonpath.findall()'.
Ensure the JSONPath expression is correctly formatted and does not include unsupported characters.
Replace the forward slash with a valid character or adjust the JSONPath expression to avoid using unsupported characters.
Ensure the question mark is used appropriately in filter expressions, such as '[?(@.field == value)]'.
No dependency data recorded yet.