What does the zip operator do in DataWeave?
What does the zip operator do in DataWeave?
The zip operator in DataWeave takes two lists (arrays) and merges them into a single list by creating pairs of elements from the same index in each list. For every element at index `i` in the first list, it pairs it with the element at index `i` in the second list, resulting in a list of these pairs.
The first sub-array in the output array contains the first indices of the input sub-arrays. The second index contains the second indices of the inputs, the third contains the third indices, and so on for every case where there are the same number of indices in the arrays. https://docs.mulesoft.com/dataweave/2.4/dw-core-functions-zip
Sample: %dw 2.0 output application/json --- [1, 2, 3] zip ["A", "B", "C"] Output: [ [1, "A"], [2, "B"], [3, "C"] ]
ZIP function merges elements from two arrays into an array of arrays.
it's bit tricky: As per document: Merges elements from two arrays into an array of arrays. here it's mentioned merge into a single list. seems correct but not sure.