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:
- A string expression evaluated by MozJexl
- An array of nested transforms for processing sub-objects
Simple expression transforms
- Input
- Output
- Transforms
{
"firstName": "Alice",
"lastName": "Smith",
"age": 17,
"price": 100,
"quantity": 3
}
{
"firstName": "Alice",
"lastName": "Smith",
"age": 17,
"fullName": "Alice Smith",
"ageInMonths": 204,
"isAdult": false,
"total": 330
}
[
{ "fullName": "input.firstName + ' ' + input.lastName" },
{ "ageInMonths": "input.age * 12" },
{ "isAdult": "input.age >= 18" },
{ "total": "input.price * input.quantity" }
]
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 ofinput)
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:
| Category | Operators / Syntax |
|---|---|
| Arithmetic | +, -, *, /, % |
| Comparison | ==, !=, <, >, <=, >= |
| Logical | &&, ||, ! |
| Ternary | condition ? trueVal : falseVal |
| String concat | + |
| Property access | obj.prop, obj['prop'] |
| Array indexing | arr[0] |
| Transforms (pipe) | value | transformName(args) |