I am on Mule 4. I need to create a "filter string" (to be used in an API call) from an array. A sample input array is given below:
[
"123AAA","123BBB","123CCC","123DDD","123EEE"
]
I need to get an output string like this using dataweave 2.0 ID = '123AAA#DT' OR ID = '123BBB#DT' OR ID = '123CCC#DT' OR ID = '123DDD#DT' OR ID = '123EEE#DT'
I tried using joinBy function but since this is in an array, it was giving an error. Please advise.
It seems a good candidate for reduce ().
%dw 2.0
output application/json
---
payload reduce ((item, accumulator="") -> "ID = '" ++ item ++ "#DT'" ++ (if (accumulator != "") " OR " ++ accumulator else "" ))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.