%dw 1.0 %output application/json %var list1 = flowVars.var1
%var list2 = flowVars.var2
I have 2 lists list1 and list2 like below.
list1 = [{"empId": "123", "firstName":"John", "lastName":"Doe"},
{"empId": "456", "firstName":"Anna", "lastName":"Smith"},
{"empId" : "567", "firstName":"Peter", "lastName":"Jones"}]
list2 = [{"empId": "567", "title":"developer"},
{"empId": "123", "title":"tester"},
{"empId": "456", "title":"manager"}]
how can i create list3 using list1 and list2? For each employee in list1, iterate over list2, get the title from list2 and create list3.
list3 = [{"empId" : "123", "firstName":"John", "lastName":"Doe",
"title" : "tester"},
{"empId" : "456", "firstName":"Anna", "lastName":"Smith",
"title" : "manager"} ,
{"empId" : "567", "firstName":"Peter", "lastName":"Jones",
"title" : "developer"} ]