Reputation: 77
I have input payload coming like this -
[ { "a": "" }, { "a": "abc" }, { "a": "pqr" }, { "a": "xyz" } ] and desired output is abc,pqr,xyz
I tried following dwl but couldn't succeed. Here is the code snippet
%dw 2.0
query : payload filter ($.a != '') map ( $.a )
Can someone please help me with the dataweave ? Thanks.
Upvotes: 1
Views: 2409
Reputation: 11606
query: joinBy(payload.a filter $ !="", ',')
Upvotes: 0
Reputation: 568
If your desired output is the string "abc,pqr,xyz":
%dw 2.0
output application/json
---
payload filter ($.a != "") map ($.a) joinBy ","
If you are trying to get the array ["abc", "pqr", "xyz"]: Your code is fine...
%dw 2.0
output application/json
---
payload filter ($.a != "") map ($.a)
Upvotes: 3