Expressions
Expressions in Datadance are written using the MozJexl expression language. They are JavaScript-like expressions that are safely evaluated against the input and derived contexts.
Basic operations
| Type | Operators |
|---|---|
| Arithmetic | +, -, *, /, % |
| Comparison | ==, !=, <, >, <=, >= |
| Logical | &&, ||, ! |
| Ternary | condition ? valueIfTrue : valueIfFalse |
| String concat | + |
Context variables
input— The original input data object (immutable)derived— The current derived state (mutable, accumulates as transforms execute)
- Input
- Transforms
- Output
{
"name": "Alice",
"price": 50,
"taxRate": 0.1,
"age": 20
}
[
{ "greeting": "'Hello, ' + input.name" },
{ "total": "input.price * (1 + input.taxRate)" },
{ "status": "input.age >= 18 ? 'adult' : 'minor'" }
]
{
"greeting": "Hello, Alice",
"total": 55,
"status": "adult"
}
Transforms (pipe syntax)
MozJexl uses a pipe | syntax to apply built-in transform functions:
value | transformName(args)
| Expression | Result |
|---|---|
"hello" | upper | "HELLO" |
[1,2,3] | join(', ') | "1, 2, 3" |
'42' | parseInt | 42 |
Transforms can be chained:
input.name | lower | capitalize
Custom operators
Datadance adds two custom binary operators:
_=— Case-insensitive string equality:"Hello" _= "hello"returnstrue===— Strict equality (type + value):"5" === 5returnsfalse