%dw 2.0 output application/json --- unzip([ [0,"a"], [1,"b"], [2,"c"],[ 3,"d"] ])
Performs the opposite of
zip. It takes an array of arrays as input.
The function groups the values of the input sub-arrays by matching indices, and it outputs new sub-arrays with the values of those matching indices. No sub-arrays are produced for unmatching indices. For example, if one input sub-array contains four elements (indices 0-3) and another only contains three (indices 0-2), the function will not produce a sub-array for the value at index 3.
This example unzips an array of arrays. It outputs the first index of each
sub-array into one array
[ 0, 1, 2, 3 ], and the second index of each into
[ "a", "b", "c", "d" ].
This example unzips an array of arrays. Notice that the number of elements in the input arrays is not all the same. The function creates only as many full sub-arrays as it can, in this case, just one.