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.


Share this:
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Jay
Jay
9 months ago

can you please let me know how to convert the below:
input:
[“ABC”
“DEF”]
output:
“ABC”, “DEF”

ppnam
9 months ago
Reply to  Jay

payload joinBy (“,” )