Skip to content

#average

Returns the average of an array of numbers, optionally after a projection.

#average(array, @x: projection?)
Category Grouping and aggregationValid in Property value
Name Type Description
array path | array The numbers, or elements to project.
projection (optional) lambda Selects the number from each element.

number

source.json
{
"numbers": [ 1, 2, 3, 4 ]
}
transformer.json
{
"result": "#average($.numbers)"
}
output.json
{
"result": 2.5
}

Try it in the playground →

#sum · #min · #max