Skip to main content

Transforms

A transform is an instruction that tells Datadance how to derive a field's value. Transforms are written as an array of objects, where each object has a single key (the output field name) and a value (the expression or nested transform).

Structure

Each transform object must contain exactly one key. The key becomes the field name in the output, and the value is either:

  1. A string expression evaluated by MozJexl
  2. An array of nested transforms for processing sub-objects

Simple expression transforms

{
"firstName": "Alice",
"lastName": "Smith",
"age": 17,
"price": 100,
"quantity": 3
}

Expression context

Expressions have access to two contexts:

  • input — The original input data object (immutable)
  • derived — The accumulated derived state (mutable, starts as a clone of input)

Transform expressions are evaluated in order, so later transforms can reference the results of earlier ones via the derived context:

[
{ "base": "input.price * 1.1" },
{ "total": "derived.base + input.tax" }
]

Expression language

Datadance uses MozJexl as its expression language. It supports:

CategoryOperators / Syntax
Arithmetic+, -, *, /, %
Comparison==, !=, <, >, <=, >=
Logical&&, ||, !
Ternarycondition ? trueVal : falseVal
String concat+
Property accessobj.prop, obj['prop']
Array indexingarr[0]
Transforms (pipe)value | transformName(args)