Python bindings for JSONata
Project description
pyjsonata
Python bindings for JSONata.
Building
Required build tools:
- npm
- clang
- make
If you want to run tests:
- pytest
To build:
Ready?
-
Install docker
-
From the repository root:
git submodule update --init --recursive rm -rf dist build __pycache__ pyjsonata.egg-info docker pull quay.io/pypa/manylinux2014_x86_64 docker run -it --mount type=bind,source=$(pwd),target=/src quay.io/pypa/manylinux2014_x86_64 /src/docker-build.sh
-
If the stars have aligned, and it is Tuesday, you will now have a built
pyjsonata
wheel -
If you are me:
python3 -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*manylinux2014_x86_64.whl
The best part about all this is that it builds a .so
using the build
procedure for CPython extensions provided by setuptools. This isn't even a
CPython extension. It just uses ctypes. But there isn't any packaging support
at all for people who use the runtime-agnostic FFI library built into Python.
Building this package is harder than writing it. Thank you, Python.
Testing
Pytest
From the repository root:
python3 -m pip install pytest
python3 -m pytest
Usage
from pyjsonata import jsonata
my_expression = "$"
my_json = "{'foo': 'bar'}"
# "{'foo': 'bar'}"
result = jsonata(my_expression, my_json)
With exception handling:
from pyjsonata import jsonata, PyjsonataError
my_expression = "$"
my_json = "{'foo': 'bar'}"
# "{'foo': 'bar'}"
try:
result = jsonata(my_expression, my_json)
except PyjsonataError as e:
print("Error: ", e)
That's it! Return values are always strings.
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 Distributions
Built Distribution
Hashes for pyjsonata-0.0.1a8-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91860765a9be74024c56c696ad12e3474a970a82845178c27da2868c963fd2e5 |
|
MD5 | b08bf24d74383b0a3c9334c621e9bc6b |
|
BLAKE2b-256 | 9230d72fb9f3675dc9b2a6e4f82dd5f5e2521818a5b33056b536f3ca84bc7d3b |