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
5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Jay
Jay
2 years ago

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

ppnam
2 years ago
Reply to  Jay

payload joinBy (“,” )

Rasool
Rasool
1 year ago

” Object”:[
{ “Name”: “xyz”},
{“Name”: “AbC”}]

Need to convert above array of object into string in single line

Rutuja
Rutuja
9 months ago
Reply to  Rasool

%dw 2.0
output application/json

payload.Name joinBy (“,”)

Amar
Amar
26 days ago
Reply to  Rasool

payload.Name joinBy(“”)