JSONata Expressions

Overview

JSONata is an expression language for querying and transforming JSON. In DataPipeline, it is used to navigate nested data, evaluate expressions, and construct output structures.

Path Operators

Operator Description Example
. Map operator used to navigate child values. Account.Order.Product.Price
[] Filter predicate used to select matching items. Account.Order.Product[Price > 100]
^() Order-by operator for sorting values. Account.Order.Product^(Price)
{} Object constructor for grouping and reshaping. Account.Order.Product{"name": Name, "price": Price}
* Wildcard selector for all children of an object. Account.*
** Descendant wildcard selector. **.Price

Predicates, Functions and Operators

JSONata supports predicates, arithmetic and comparison operators, and built-in functions.

  • Predicates: Product[Category = "Books"]
  • Arithmetic: Price * Quantity
  • Comparison: Price >= 50
  • Functions: $sum(Account.Order.Product.Price), $count(Account.Order.Product), $substring("DataPipeline", 0, 4)

Variables

Assign variables with := and reuse them within an expression.

($p := Account.Order.Product; $p[Price > 100].Name)

Transforming Output

Use expressions to generate new JSON structures from source data.

{"customer": Account.Customer.Name, "total": $sum(Account.Order.Product.(Price * Quantity))}

JSONata Examples

DataPipeline examples:

Further Reading

For complete language details, see docs.jsonata.org/overview.html.

Mobile Analytics