How do I map corresponding elements in dataweave for eg: map CUSTOMER_ID : 790280, CUSTOMER_NAME : JAMES
[
["CUSTOMER_ID", "CUSTOMER_NAME", "AGE", "ADDRESS", "DESCRIPTION"],
["790280", "JAMES", "25", "", ""]
]
Yup sure @Bharath Kumar N J​ ,
I have two solutions in this case:
Solution 1:
In last script, remove the filter from the end as under:
%dw 2.0
output application/json
---
read((write(payload)
replace '[' with '' replace ']' with '' replace ', \n ' with ','
replace '\n , \n' with '' replace ' ' with ''), 'application/csv')
Solution 2: Use another script as under:
%dw 2.0
output application/json
---
(payload[1 to -1] map (item, index) -> (item reduce ((item1, acc1={}) -> acc1 ++ ('key') : item1)))map (object) -> (object mapObject ((value, key, index) -> (payload[0][index]): value))
Both worked fine for me. Already tested.
Once it will work for you, upvote the answer, so that if someone else have same issue, then they may get the correct solution.
Regards,
Lalit Panwar