Skip to main content

Extensions for JSONPath RW

Project description

===============================
python-jsonpath-rw-ext
===============================

.. image:: https://travis-ci.org/sileht/python-jsonpath-rw-ext.png?branch=master
:target: https://travis-ci.org/sileht/python-jsonpath-rw-ext

.. image:: https://img.shields.io/pypi/v/jsonpath-rw-ext.svg
:target: https://pypi.python.org/pypi/jsonpath-rw-ext/
:alt: Latest Version

.. image:: https://img.shields.io/pypi/dm/jsonpath-rw-ext.svg
:target: https://pypi.python.org/pypi/jsonpath-rw-ext/
:alt: Downloads

Extensions for JSONPath RW

This extensions will be proposed `upstream <https://github.com/kennknowles/python-jsonpath-rw>`__
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 | - $.objects.`len` |
+--------------+----------------------------------------------+
| sorted | - $.objects.`sorted` |
| | - $.objects[\\some_field] |
| | - $.objects[\\some_field,/other_field] |
+--------------+----------------------------------------------+
| filter | - $.objects[?(@some_field > 5)] |
| | - $.objects[?some_field = "foobar")] |
| | - $.objects[?some_field > 5 & other < 2)] |
+--------------+----------------------------------------------+
| arithmetic | - $.foo + "_" + $.bar |
| (-+*/) | - $.foo * 12 |
| | - $.objects[*].cow + $.objects[*].cat |
+--------------+----------------------------------------------+

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**

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]**

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonpath-rw-ext-0.1.6.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

jsonpath_rw_ext-0.1.6-py2.py3-none-any.whl (14.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jsonpath-rw-ext-0.1.6.tar.gz.

File metadata

File hashes

Hashes for jsonpath-rw-ext-0.1.6.tar.gz
Algorithm Hash digest
SHA256 35a30b5350e36ddb055463dbff569718341af443f334b78a31af7deeff9c6ef0
MD5 1af0066ee0a557183b7681e17e8ef0a2
BLAKE2b-256 43c7c664bab10d572cecbdad8e8569b788ed6dc3d38ec7b49c4fa855ce6e1abb

See more details on using hashes here.

File details

Details for the file jsonpath_rw_ext-0.1.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for jsonpath_rw_ext-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a8486efdd81174f907c08061f3691144cda88ce31aa7b9888640ee388bf14827
MD5 564ddd2fcd4b2d428f18fde1d629debb
BLAKE2b-256 1c14789e8073c66b2db7f6d7b12da1a7beb6618fe98b77ed1296934de9b24b15

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page