%dw 2.0
output application/json
---
{ a: avg([1, 1000]), b: avg([1, 2, 3]) }
DataWeave
avg
avg(Array<Number>): Number
Returns the average of numbers listed in an array.
An array that is empty or that contains a non-numeric value results in an error.
Parameters
Name | Description |
---|---|
|
The input array of numbers. |
Example
This example returns the average of multiple arrays.
Source
Output
{ "a": 500.5, "b": 2.0 }
JSON