99e9162584 | ||
---|---|---|
doc/source | ||
jsonpath_rw_ext | ||
.coveragerc | ||
.gitignore | ||
.gitreview | ||
.mailmap | ||
.testr.conf | ||
.travis.yml | ||
CONTRIBUTING.rst | ||
HACKING.rst | ||
LICENSE | ||
MANIFEST.in | ||
README.rst | ||
babel.cfg | ||
openstack-common.conf | ||
releases.sh | ||
requirements.txt | ||
setup.cfg | ||
setup.py | ||
test-requirements.txt | ||
tox.ini |
README.rst
python-jsonpath-rw-ext
Extensions for JSONPath RW
This 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/
- Source: http://github.com/sileht/python-jsonpath-rw-ext
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
Extensions
name | Example |
---|---|
len |
|
sorted |
|
filter |
|
arithmetic (-+*/) |
|
About arithmetic and string
Operations are done with python operators and allows types that python allows, and return None if the operation can be done due to imcompatible types.
When operators are used, a jsonpath must be be fully defined otherwise if jsonpath-rw-ext can't known if expression is a string or a jsonpath field, it will choice string.
Example with data:
{
'cow': 'foo',
'fish': 'bar'
}
cow + fish returns
cowfish
$.cow + $.fish returns foobar
$.cow + "_" + $.fish returns foo_bar
$.cow + "_" + fish returns foo_fish
$.cow + $.fish returns foobar
$.cow + "_" + $.fish returns foo_bar
$.cow + "_" + fish returns foo_fish
About arithmetic and list
Arithmetic can be used against two list if they have the same size.
Example with data:
{'objects': [
{'cow': 2, 'cat': 3},
{'cow': 4, 'cat': 6}
]}
$.objects[*].cow +
$.objects[*].cat returns [6, 9]