Extensions for JSONPath RW
Project description
Extensions for JSONPath RW
jsonpath-rw-ext extends json-path-rw capabilities by adding multiple extensions. ‘len’ that allows one to get the length of a list. ‘sorted’ that returns a sorted version of a list, ‘arithmetic’ that permits one to make math operation between elements and ‘filter’ to select only certain elements of a list.
Each extensions will be proposed upstream and will stay here only if they are refused.
Free software: Apache license
Documentation: https://python-jsonpath-rw-ext.readthedocs.org/en/latest/
Quick Start
At the command line:
$ pip install jsonpath-rw-ext
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv jsonpath-rw-ext $ pip install jsonpath-rw-ext
To replace the jsonpath_rw parser by this one with:
import jsonpath_rw_ext jsonpath_rw_ext.parse("$.foo").find(...)
Or:
from jsonpath_rw_ext import parser parser.ExtentedJsonPathParser().parse("$.foo").find(...)
The jsonpath classes are not part of the public API, because the name/structure can change when they will be implemented upstream. Only the syntax shouldn’t change.
Extensions
name |
Example |
---|---|
len |
|
sub |
|
split |
|
sorted |
|
filter |
|
arithmetic (-+*/) |
|
About arithmetic and string
Operations are done with python operators and allows types that python allows, and return [] if the operation can be done due to incompatible types.
When operators are used, a jsonpath must be be fully defined otherwise jsonpath-rw-ext can’t known if the expression is a string or a jsonpath field, in this case it will choice string as type.
Example with data:
{ 'cow': 'foo', 'fish': 'bar' }
About arithmetic and list
Arithmetic can be used against two lists if they have the same size.
Example with data:
{'objects': [ {'cow': 2, 'cat': 3}, {'cow': 4, 'cat': 6} ]}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jsonpath-rw-ext-1.1.0.tar.gz
.
File metadata
- Download URL: jsonpath-rw-ext-1.1.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 835a6e453babcfe4c8582b99787ab73635e9b16d3982a3b0deff3eeac05746ab |
|
MD5 | cdc836db180e3c0ec59b70f168f61c35 |
|
BLAKE2b-256 | 84ea5d9238b4847bf699b66c4bc73c6b9c9e95f1690b6c87fd57a544c98c6e3e |
Provenance
File details
Details for the file jsonpath_rw_ext-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: jsonpath_rw_ext-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4872ce86f8717857b1a9c6403a0389124d0757d63b564187c9eba04e38e1ee4c |
|
MD5 | 08d3066cc29c3152fc19b8f22b10f377 |
|
BLAKE2b-256 | 0ef2c6873c67fbc075de364eb41a32256a4e60866431c6215953154ebe37e487 |