python-jsonpath 1.3.1
pip install python-jsonpath
Released:
JSONPath, JSON Pointer and JSON Patch for Python.
Navigation
Unverified details
These details havenot been verified by PyPIProject links
Meta
- License Expression: MIT
SPDXLicense Expression - Author:James Prior
- Requires: Python >=3.8
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
Project description
Python JSONPath
A flexible JSONPath engine for Python.
We followRFC 9535 and test against theJSONPath Compliance Test Suite.
Table of Contents
Install
Install Python JSONPath usingpip:
pip install python-jsonpath
OrPipenv:
pipenv install -u python-jsonpath
Or fromconda-forge:
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 - A Python implementation of JSONPath that follows RFC 9535 much more strictly. If you require maximum interoperability with JSONPath implemented in other languages - at the expense of extra features - choosejsonpath-rfc9535 overpython-jsonpath.
jsonpath-rfc9535 matches RFC 9535's JSONPath model internally and is careful to use the spec's terminology. It also includes utilities for verifying and testing theJSONPath Compliance Test Suite. Most notably the nondeterministic behavior of some JSONPath selectors.
JSON P3 - RFC 9535 implemented in TypeScript. JSON P3 does not include all the non-standard features of Python JSONPath, but does define some optionalextra syntax.
Ruby JSON P3 - RFC 9535, RFC 6901 and RFC 6902 implemented in Ruby.
Examples
JSONPath
importjsonpathdata={"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 anRFC 6901 compliant implementation of JSON Pointer. See JSON Pointerquick start,guide andAPI reference
fromjsonpathimportpointerdata={"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)# 100jane_score=pointer.resolve(["users",3,"score"],data)print(jane_score)# 55
JSON Patch
We also include anRFC 6902 compliant implementation of JSON Patch. See JSON Patchquick start andAPI reference
fromjsonpathimportpatchpatch_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 theMIT license.
Project details
Unverified details
These details havenot been verified by PyPIProject links
Meta
- License Expression: MIT
SPDXLicense Expression - Author:James Prior
- Requires: Python >=3.8
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
Release historyRelease notifications |RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more aboutinstalling packages.
Source Distribution
Built Distribution
File details
Details for the filepython_jsonpath-1.3.1.tar.gz
.
File metadata
- Download URL:python_jsonpath-1.3.1.tar.gz
- Upload date:
- Size: 43.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90d348be9c6f0ee070cb6419d4b2b08fcbb07f5a2a34060b8833bef024099315 | |
MD5 | 3d0dd8190173a4701305ef64bba4e2f4 | |
BLAKE2b-256 | 8e99767bb6fddf6686f6bb5855bc7895b7ccaa50fe92c06eb92f3308a5571787 |
File details
Details for the filepython_jsonpath-1.3.1-py3-none-any.whl
.
File metadata
- Download URL:python_jsonpath-1.3.1-py3-none-any.whl
- Upload date:
- Size: 54.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df33fcd56ed6f3eef2eae990b74719c4111f709247ed73cbe1b088063a1aac0c | |
MD5 | 56af71800e1e7572499ad79c57a7ac06 | |
BLAKE2b-256 | 5beeac03351487f22aa7b505185cd53180e82b925c145d96b1ef77d308dcdce4 |