Contact Free trial Login


flatMap(Array<T>, (item: T, index: Number) -> Array<R>): Array<R>

Applies a transformation function to each element in a list (array) and then flattens the result.

Instead of returning an array of arrays (as map does), it returns a flattened array (see the flatten function).


Name Description


The list (Array type) to map.


The item and/or index in the list to flatten.


This example returns an array containing each index and item in order. Note that you can also write the example like this: { "users" : ["joe", "pete", "matt"] flatMap ([$$ as String, $]) }


%dw 2.0
output application/json
{ "users" : ["joe", "pete", "matt"] flatMap (item, index) -> ([index as String, item]) }


   "users": [

flatMap(Null, (item: Nothing, index: Nothing) -> Any): Null

Helper function that allows flatMap to work with null values.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.