<h1 align="center">Python JSONPath</h1>
<p align="center">
A flexible JSONPath engine for Python.
<br>
We follow <a href="https://datatracker.ietf.org/doc/html/rfc9535">RFC 9535</a> and test against the <a href="https://github.com/jsonpath-standard/jsonpath-compliance-test-suite">JSONPath Compliance Test Suite</a>.
</p>
<p align="center">
<a href="https://github.com/jg-rp/python-jsonpath/blob/main/LICENSE.txt">
<img src="https://img.shields.io/pypi/l/python-jsonpath?style=flat-square" alt="License">
</a>
<a href="https://github.com/jg-rp/python-jsonpath/actions">
<img src="https://img.shields.io/github/actions/workflow/status/jg-rp/python-jsonpath/tests.yaml?branch=main&label=tests&style=flat-square" alt="Tests">
</a>
<a href="https://pypi.org/project/python-jsonpath">
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/python-jsonpath?style=flat-square">
</a>
<br>
<a href="https://pypi.org/project/python-jsonpath">
<img src="https://img.shields.io/pypi/v/python-jsonpath.svg?style=flat-square" alt="PyPi - Version">
</a>
<a href="https://pypi.org/project/python-jsonpath">
<img src="https://img.shields.io/pypi/pyversions/python-jsonpath.svg?style=flat-square" alt="Python versions">
</a>
</p>
---
**Table of Contents**
- [Install](#install)
- [Links](#links)
- [Related projects](#related-projects)
- [Examples](#examples)
- [License](#license)
## Install
Install Python JSONPath using [pip](https://pip.pypa.io/en/stable/getting-started/):
```
pip install python-jsonpath
```
Or [Pipenv](https://pipenv.pypa.io/en/latest/):
```
pipenv install -u python-jsonpath
```
Or from [conda-forge](https://anaconda.org/conda-forge/python-jsonpath):
```
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
## Related projects
- [JSONPath RFC 9535](https://github.com/jg-rp/python-jsonpath-rfc9535) - A minimal, slightly cleanr Python implementation of RFC 9535. If you're not interested JSONPath sytax beyond that defined in RFC 9535, you might choose [jsonpath-rfc9535](https://pypi.org/project/jsonpath-rfc9535/) over [python-jsonpath](https://pypi.org/project/python-jsonpath/).
jsonpath-rfc9535 also includes utilities for verifying and testing the [JSONPath Compliance Test Suite](https://github.com/jsonpath-standard/jsonpath-compliance-test-suite). Most notably the nondeterministic behavior of some JSONPath selectors.
- [JSON P3](https://github.com/jg-rp/json-p3) - RFC 9535 implemented in TypeScript. JSON P3 does not include all the non-standard features of Python JSONPath, but does define some optional [extra syntax](https://jg-rp.github.io/json-p3/guides/jsonpath-extra).
- [Ruby JSON P3](https://github.com/jg-rp/ruby-json-p3) - RFC 9535, RFC 6901 and RFC 6902 implemented in Ruby.
## Examples
### JSONPath
```python
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
We include an [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) compliant implementation of JSON Pointer. See JSON Pointer [quick start](https://jg-rp.github.io/python-jsonpath/quickstart/#pointerresolvepointer-data), [guide](https://jg-rp.github.io/python-jsonpath/pointers/) and [API reference](https://jg-rp.github.io/python-jsonpath/api/#jsonpath.JSONPointer)
```python
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
```
### JSON Patch
We also include an [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) compliant implementation of JSON Patch. See JSON Patch [quick start](https://jg-rp.github.io/python-jsonpath/quickstart/#patchapplypatch-data) and [API reference](https://jg-rp.github.io/python-jsonpath/api/#jsonpath.JSONPatch)
```python
from jsonpath import patch
patch_operations = [
{"op": "add", "path": "/some/foo", "value": {"foo": {}}},
{"op": "add", "path": "/some/foo", "value": {"bar": []}},
{"op": "copy", "from": "/some/other", "path": "/some/foo/else"},
{"op": "add", "path": "/some/foo/bar/-", "value": 1},
]
data = {"some": {"other": "thing"}}
patch.apply(patch_operations, data)
print(data) # {'some': {'other': 'thing', 'foo': {'bar': [1], 'else': 'thing'}}}
```
## License
`python-jsonpath` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
Raw data
{
"_id": null,
"home_page": null,
"name": "python-jsonpath",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "JSON, JSON Patch, JSON Path, JSON Pointer, JSONPath, RFC 9535",
"author": null,
"author_email": "James Prior <jamesgr.prior@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f3/db/f1f19205b0df6eb0195de154dc6c967448802dfb573487fa8a4206a243cd/python_jsonpath-2.0.1.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">Python JSONPath</h1>\n\n<p align=\"center\">\nA flexible JSONPath engine for Python.\n<br>\nWe follow <a href=\"https://datatracker.ietf.org/doc/html/rfc9535\">RFC 9535</a> and test against the <a href=\"https://github.com/jsonpath-standard/jsonpath-compliance-test-suite\">JSONPath Compliance Test Suite</a>.\n</p>\n\n<p align=\"center\">\n <a href=\"https://github.com/jg-rp/python-jsonpath/blob/main/LICENSE.txt\">\n <img src=\"https://img.shields.io/pypi/l/python-jsonpath?style=flat-square\" alt=\"License\">\n </a>\n <a href=\"https://github.com/jg-rp/python-jsonpath/actions\">\n <img src=\"https://img.shields.io/github/actions/workflow/status/jg-rp/python-jsonpath/tests.yaml?branch=main&label=tests&style=flat-square\" alt=\"Tests\">\n </a>\n <a href=\"https://pypi.org/project/python-jsonpath\">\n <img alt=\"PyPI - Downloads\" src=\"https://img.shields.io/pypi/dm/python-jsonpath?style=flat-square\">\n </a>\n <br>\n <a href=\"https://pypi.org/project/python-jsonpath\">\n <img src=\"https://img.shields.io/pypi/v/python-jsonpath.svg?style=flat-square\" alt=\"PyPi - Version\">\n </a>\n <a href=\"https://pypi.org/project/python-jsonpath\">\n <img src=\"https://img.shields.io/pypi/pyversions/python-jsonpath.svg?style=flat-square\" alt=\"Python versions\">\n </a>\n</p>\n\n---\n\n**Table of Contents**\n\n- [Install](#install)\n- [Links](#links)\n- [Related projects](#related-projects)\n- [Examples](#examples)\n- [License](#license)\n\n## Install\n\nInstall Python JSONPath using [pip](https://pip.pypa.io/en/stable/getting-started/):\n\n```\npip install python-jsonpath\n```\n\nOr [Pipenv](https://pipenv.pypa.io/en/latest/):\n\n```\npipenv install -u python-jsonpath\n```\n\nOr from [conda-forge](https://anaconda.org/conda-forge/python-jsonpath):\n\n```\nconda install -c conda-forge python-jsonpath\n```\n\n## Links\n\n- Documentation: https://jg-rp.github.io/python-jsonpath/.\n- JSONPath Syntax: https://jg-rp.github.io/python-jsonpath/syntax/\n- Change log: https://github.com/jg-rp/python-jsonpath/blob/main/CHANGELOG.md\n- PyPi: https://pypi.org/project/python-jsonpath\n- Source code: https://github.com/jg-rp/python-jsonpath\n- Issue tracker: https://github.com/jg-rp/python-jsonpath/issues\n\n## Related projects\n\n- [JSONPath RFC 9535](https://github.com/jg-rp/python-jsonpath-rfc9535) - A minimal, slightly cleanr Python implementation of RFC 9535. If you're not interested JSONPath sytax beyond that defined in RFC 9535, you might choose [jsonpath-rfc9535](https://pypi.org/project/jsonpath-rfc9535/) over [python-jsonpath](https://pypi.org/project/python-jsonpath/).\n\n jsonpath-rfc9535 also includes utilities for verifying and testing the [JSONPath Compliance Test Suite](https://github.com/jsonpath-standard/jsonpath-compliance-test-suite). Most notably the nondeterministic behavior of some JSONPath selectors.\n\n- [JSON P3](https://github.com/jg-rp/json-p3) - RFC 9535 implemented in TypeScript. JSON P3 does not include all the non-standard features of Python JSONPath, but does define some optional [extra syntax](https://jg-rp.github.io/json-p3/guides/jsonpath-extra).\n\n- [Ruby JSON P3](https://github.com/jg-rp/ruby-json-p3) - RFC 9535, RFC 6901 and RFC 6902 implemented in Ruby.\n\n## Examples\n\n### JSONPath\n\n```python\nimport jsonpath\n\ndata = {\n \"users\": [\n {\"name\": \"Sue\", \"score\": 100},\n {\"name\": \"John\", \"score\": 86},\n {\"name\": \"Sally\", \"score\": 84},\n {\"name\": \"Jane\", \"score\": 55},\n ]\n}\n\nuser_names = jsonpath.findall(\"$.users[?@.score < 100].name\", data)\nprint(user_names) # ['John', 'Sally', 'Jane']\n```\n\n### JSON Pointer\n\nWe include an [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) compliant implementation of JSON Pointer. See JSON Pointer [quick start](https://jg-rp.github.io/python-jsonpath/quickstart/#pointerresolvepointer-data), [guide](https://jg-rp.github.io/python-jsonpath/pointers/) and [API reference](https://jg-rp.github.io/python-jsonpath/api/#jsonpath.JSONPointer)\n\n```python\nfrom jsonpath import pointer\n\ndata = {\n \"users\": [\n {\"name\": \"Sue\", \"score\": 100},\n {\"name\": \"John\", \"score\": 86},\n {\"name\": \"Sally\", \"score\": 84},\n {\"name\": \"Jane\", \"score\": 55},\n ]\n}\n\nsue_score = pointer.resolve(\"/users/0/score\", data)\nprint(sue_score) # 100\n\njane_score = pointer.resolve([\"users\", 3, \"score\"], data)\nprint(jane_score) # 55\n```\n\n### JSON Patch\n\nWe also include an [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) compliant implementation of JSON Patch. See JSON Patch [quick start](https://jg-rp.github.io/python-jsonpath/quickstart/#patchapplypatch-data) and [API reference](https://jg-rp.github.io/python-jsonpath/api/#jsonpath.JSONPatch)\n\n```python\nfrom jsonpath import patch\n\npatch_operations = [\n {\"op\": \"add\", \"path\": \"/some/foo\", \"value\": {\"foo\": {}}},\n {\"op\": \"add\", \"path\": \"/some/foo\", \"value\": {\"bar\": []}},\n {\"op\": \"copy\", \"from\": \"/some/other\", \"path\": \"/some/foo/else\"},\n {\"op\": \"add\", \"path\": \"/some/foo/bar/-\", \"value\": 1},\n]\n\ndata = {\"some\": {\"other\": \"thing\"}}\npatch.apply(patch_operations, data)\nprint(data) # {'some': {'other': 'thing', 'foo': {'bar': [1], 'else': 'thing'}}}\n\n```\n\n## License\n\n`python-jsonpath` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n",
"bugtrack_url": null,
"license": null,
"summary": "JSONPath, JSON Pointer and JSON Patch for Python.",
"version": "2.0.1",
"project_urls": {
"Documentation": "https://jg-rp.github.io/python-jsonpath/",
"Issues": "https://github.com/jg-rp/python-jsonpath/issues",
"Source": "https://github.com/jg-rp/python-jsonpath"
},
"split_keywords": [
"json",
" json patch",
" json path",
" json pointer",
" jsonpath",
" rfc 9535"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d8d464d7cdc01269f5fed45e6a69f5395c30451958c299ca5cbc1442a4f3f9b9",
"md5": "f032cb32b4e2755098282b461b18b84b",
"sha256": "ebd518b7c883acc5b976518d76b6c96288405edec7d9ef838641869c1e1a5eb7"
},
"downloads": -1,
"filename": "python_jsonpath-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f032cb32b4e2755098282b461b18b84b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 64060,
"upload_time": "2025-09-13T08:01:46",
"upload_time_iso_8601": "2025-09-13T08:01:46.184747Z",
"url": "https://files.pythonhosted.org/packages/d8/d4/64d7cdc01269f5fed45e6a69f5395c30451958c299ca5cbc1442a4f3f9b9/python_jsonpath-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f3dbf1f19205b0df6eb0195de154dc6c967448802dfb573487fa8a4206a243cd",
"md5": "cbbea11b551c98d804697a1a4253bd64",
"sha256": "32a84ebb2dc0ec1b42a6e165b0f9174aef8310bad29154ad9aee31ac37cca18f"
},
"downloads": -1,
"filename": "python_jsonpath-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "cbbea11b551c98d804697a1a4253bd64",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 49659,
"upload_time": "2025-09-13T08:01:47",
"upload_time_iso_8601": "2025-09-13T08:01:47.820038Z",
"url": "https://files.pythonhosted.org/packages/f3/db/f1f19205b0df6eb0195de154dc6c967448802dfb573487fa8a4206a243cd/python_jsonpath-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-13 08:01:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jg-rp",
"github_project": "python-jsonpath",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "python-jsonpath"
}