JSONata for Python

0.6.2 · active · verified Mon Apr 13

jsonata-python is a pure Python implementation of the JSONata query and transformation language, currently at version 0.6.2. It aims to provide 100% of the language features of JSONata without external dependencies, offering a performant alternative to Python libraries that rely on JavaScript bindings. The library maintains a steady release cadence with updates reflecting the upstream JSONata specification.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a JSONata expression and apply it to a Python dictionary using the jsonata-python library. It calculates the sum of 'value' fields within a nested array.

import jsonata

data = {"example": [{"value": 4}, {"value": 7}, {"value": 13}]}
expr_str = "$sum(example.value)"

expr = jsonata.Jsonata(expr_str)
result = expr.evaluate(data)
print(f"JSONata expression: {expr_str}")
print(f"Input data: {data}")
print(f"Result: {result}")

view raw JSON →