Skip to main content

Python bindings for jsonata-rs

Project description

zopyx.pyjsonata

Python bindings for the Rust implementation of JSONata, powered by PyO3 and maturin. This package exposes the JSONata evaluator from jsonata-rs to Python with a small, focused API.

Quick start

Install from source (local)

UV_CACHE_DIR=/tmp/uv-cache uv venv .venv --python 3.13 --clear
UV_CACHE_DIR=/tmp/uv-cache uv pip install --python .venv/bin/python "maturin[zig]"
UV_CACHE_DIR=/tmp/uv-cache .venv/bin/python -m maturin develop --features python

Use

from zopyx.pyjsonata import evaluate, UNDEFINED, Jsonata

# Evaluate a simple expression
print(evaluate("1 + 1"))

# Evaluate with input data
print(evaluate('"Hello, " & name & "!"', {"name": "world"}))

# Provide variable bindings
bindings = {"x": 2, "y": 3}
print(evaluate("$x + $y", UNDEFINED, bindings))

# Reuse a compiled expression
expr = Jsonata("$sum([1,2,3])")
print(expr.evaluate())

API

evaluate(expr, input=UNDEFINED, bindings=None, max_depth=None, time_limit=None)

  • expr: JSONata expression string
  • input: JSON data for $ (default UNDEFINED = no input)
  • bindings: dict of variable bindings, e.g. {"x": 1}
  • max_depth: optional evaluator depth limit
  • time_limit: optional evaluation time limit

Returns standard Python types: dict, list, str, float, int, bool, None, or UNDEFINED.

Jsonata(expr)

Constructs a reusable expression object.

  • Jsonata.evaluate(...) has the same signature as evaluate but with the expression pre-parsed.

UNDEFINED

Represents missing input (distinct from JSON null). In Python, None maps to JSON null.

Errors

Errors raise ValueError and include the JSONata error code prefix (e.g. T0410), matching the Rust implementation.

Build wheels (manylinux)

UV_CACHE_DIR=/tmp/uv-cache .venv/bin/python -m maturin build \
  --release \
  --features python \
  --compatibility manylinux_2_28 \
  --interpreter python3.11 python3.12 python3.13 \
  --zig \
  --auditwheel=repair

Tests

  • Rust tests: cargo test
  • Python testsuite port: make test-python or just test-python

Limitations

This is an incomplete JSONata implementation. Many reference tests are skipped under tests/**/skip.

License

Apache-2.0.

Maintainer

Andreas Jung — info@zopyx.com

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 Distributions

If you're not sure about the file name format, learn more about wheel file names.

zopyx_pyjsonata-0.3.7-cp313-cp313-manylinux_2_28_x86_64.whl (797.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

zopyx_pyjsonata-0.3.7-cp312-cp312-manylinux_2_28_x86_64.whl (797.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

zopyx_pyjsonata-0.3.7-cp311-cp311-manylinux_2_28_x86_64.whl (799.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

File details

Details for the file zopyx_pyjsonata-0.3.7-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: zopyx_pyjsonata-0.3.7-cp313-cp313-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 797.5 kB
  • Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for zopyx_pyjsonata-0.3.7-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8d03c2d28c7f5744d34f0d4a4fa74ca92263591f6015d73726b601816e125dd
MD5 e116dacca4292f3d4ee2134072bca2a5
BLAKE2b-256 17b330142b85992fe9be0c43001ea96bbbddafd21c943c142f7ea949b575371e

See more details on using hashes here.

File details

Details for the file zopyx_pyjsonata-0.3.7-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: zopyx_pyjsonata-0.3.7-cp312-cp312-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 797.9 kB
  • Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for zopyx_pyjsonata-0.3.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8e20344e39038db682fa0f5683ace336c69993498e7fc5c65860f1f28b06ba52
MD5 67e481ca3ceec3360bf2858f7aadc8fa
BLAKE2b-256 0e51c5b72b92d46829edcc705144c607d5e5daf60d5630c59d68d19f69a81d7d

See more details on using hashes here.

File details

Details for the file zopyx_pyjsonata-0.3.7-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: zopyx_pyjsonata-0.3.7-cp311-cp311-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 799.1 kB
  • Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for zopyx_pyjsonata-0.3.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7cf165909f9721851b22ff2acccc6d7d33a3abd612fb76119376c8f9394f674a
MD5 7e11a8d7bb8d81bd269bfe5cce97e4c4
BLAKE2b-256 d82d45a5f96ce9afccb1e8f5e79fb9e04f71d066d5f6b9f5b76400b1fcc63eae

See more details on using hashes here.

Supported by

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