Skip to content

Lambdas

Several library methods take a lambda to filter, project, or otherwise refine data. A lambda declares one or more range variables, separated by semicolons, then a colon and a body expression:

@x: @x.price > 10
@acc;@current: @acc + @current

A lambda’s variables exist only inside its body.

transformer.json
{
"hasValues": "#valueOf($.some.integerArray)->#any(@x: @x > 5)",
"filteredData": "#valueOf($.some.complexArray)->#where(@x: @x.some.path < 10)",
"projectedData": "#valueOf($.some.complexArray)->#select(@x: @x.some.path)"
}
source.json
{
"some": {
"integerArray": [ 1, 2, 6, 10 ],
"complexArray": [
{ "some": { "path": 5 } },
{ "some": { "path": 30 } }
]
}
}
output.json
{
"hasValues": true,
"filteredData": [
{ "some": { "path": 5 } }
],
"projectedData": [ 5, 30 ]
}
Arity Methods
One parameter any, where, select, orderBy, orderByDesc, groupBy, summarizeWith, distinct, takeWhile, skipWhile, max, min, sum, average, try
Two parameters reduce, zip

Your own C# methods can take lambdas too. See lambdas in external methods.