Skip to main content

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyjsonata-0.0.1a7-cp36-cp36m-manylinux2014_x86_64.whl (283.7 kB view hashes)

Uploaded CPython 3.6m

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