MCD - Level 1 Exam QuestionsBrowse all questions from this exam

MCD - Level 1 Exam - Question 56


What does the zip operator do in DataWeave?

Show Answer
Correct Answer: D

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.

Discussion

4 comments
Sign in to comment
AquawormOption: D
Feb 22, 2022

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

d_ngnrOption: D
Sep 5, 2023

Sample: %dw 2.0 output application/json --- [1, 2, 3] zip ["A", "B", "C"] Output: [ [1, "A"], [2, "B"], [3, "C"] ]

kampatraOption: D
Feb 3, 2023

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.

ExamDevOption: D
Jan 25, 2024

ZIP function merges elements from two arrays into an array of arrays.