Deep into Dataweave - Mule 4
1) Use vars as an ArrayList: Define the variable as an Array List using the below blank array (Use Set Variable activity): %dw 2 . 0 output application/java --- [] Add values to the existing variable Array List (Use another Set Variable activity): %dw 2 . 0 output application/java --- vars .varList + payload Lookup values from the variable ArrayList using the index: vars.varList[ 2 ] Full flow mule xml: < flow name = "varsAsArrayList" doc:id = "ad2a593a-e7cb-4cd6-a46a-3e87d30f95f8" > < set-payload value = ' #[ % dw 2.0 output application / java --- ["First" , "Second" , "Third"] ]' doc:name = "Set Payload" doc:id = "3ec00784-0453-44ce-baa9-71dc20ebbe1d" /> < set-variable value = " #[ % dw 2.0 output application / java --- []