What is output of Dataweave flatten function?

What is output of Dataweave flatten function?
A . Object
B. Map
C. Array (Correct)
D. LInkedHashMap

Answer: C

Explanation:

Correct answer is Array.

Flatten turns a set of subarrays (such as [ [1,2,3], [4,5,[6]], [], [null] ]) into a single, flattened array (such as [ 1, 2, 3, 4, 5, [6], null ]).

This example defines three arrays of numbers, creates another array containing those three arrays, and then uses the flatten function to convert the array of arrays into a single array with all values.

Source

%dw 2.0

output application/json

var array1 = [1,2,3]

var array2 = [4,5,6]

var array3 = [7,8,9]

var arrayOfArrays = [array1, array2, array3]



flatten(arrayOfArrays)

Output

[ 1,2,3,4,5,6,7,8,9 ]

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments