Skip to main content

$$map

Returns a mapped array applying the transformer on each of the elements

Usage​

{
"$$map": [ /* values */ ],
"to": /* Transformer */
}

Returns​

array (of type of to's result)

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryarrayYesArray of elements
toTransformer(##current,##index)Input is ##current (current element) & ##index (current index)YesTransformer to map each element to its value in the result array

Alternative form​

{
"$$map": [ [ /* values */ ], /* to */]
}

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryarrayYesArray of size 2 (values, to)

Examples​

Input

Definition

Output

[
{
"a": "A1",
"id": 5
},
{
"a": "A2",
"id": 9
}
]
{ 
"$$map": "$",
"to": {
"i": "##current.id",
"m": "##current.a",
"idx": "##index"
}
}
[
{
"i": 5,
"m": "A1",
"idx": 0
},
{
"i": 9,
"m": "A2",
"idx": 1
}
]