Convert Array To String In Dataweave 2.0
You can use joinBy Dataweave 2.0 function to convert array to string
Example
Input:
[1,2,3,4,5]
Dataweave Expression:
%dw 2.0 output application/json --- { "a": payload joinBy ("-") }
Result:
{ "a": "1-2-3-4-5" }
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.
can you please let me know how to convert the below:
input:
[“ABC”
“DEF”]
output:
“ABC”, “DEF”
payload joinBy (“,” )
” Object”:[
{ “Name”: “xyz”},
{“Name”: “AbC”}]
Need to convert above array of object into string in single line
%dw 2.0
output application/json
—
payload.Name joinBy (“,”)
payload.Name joinBy(“”)