jsonata

A simple Python wrapper for the JavaScript JSONata lib.


License
BSD-3-Clause
Install
pip install jsonata==0.2.5

Documentation

JSONata-Wrapper

A really simple wrapper for the JSONata javascript library. This library is loosely based on the pyjsonata bindings.

install

python3 -m pip install jsonata

usage

import jsonata

jncontext = jsonata.Context()

try:
    result = jncontext("[$.foo, $.bar[2]]", { "foo": "hi there", "bar": [1,2,3,5,8,13]})
except ValueError as exp:
    ...

hack for usage with larger integers

By using this hack, the input JSON is patched so that all integers bigger than the JavaScript MAX_SAFE_INTEGER are converted to strings before invocating JSONata, and are converted back to integers in the result.

jncontext = jsonata.Context(bigint_patch=True)

Currently pinned to JSONata 1.8.6

Please note that due to API changes and possible implementation changes, the python JSONata module is currently pinned to version 1.8.6 of JSONata.

In short, JSONata 2.0.0 broke things, adding an 'await' to the bindings didn't fix it, and I haven't have time to look into it any deeper so far. If anyone wants to have a go at fixing it, pull requests are highly welcome at this time.