[英]how to get string values from list of maps in dataweave 2.0?
I have input payload coming like this - 我输入的有效载荷是这样的-
[ { "a": "" }, { "a": "abc" }, { "a": "pqr" }, { "a": "xyz" } ] and desired output is abc,pqr,xyz [{“ a”:“”},{“ a”:“ abc”},{“ a”:“ pqr”},{“ a”:“ xyz”}]并且期望的输出是abc,pqr,xyz
I tried following dwl but couldn't succeed. 我尝试跟随dwl,但无法成功。 Here is the code snippet
这是代码片段
%dw 2.0 %dw 2.0
query : payload filter ($.a != '') map ( $.a ) 查询:有效负载过滤器($ .a!='')映射($ .a)
Can someone please help me with the dataweave ? 有人可以帮我做数据编织吗? Thanks.
谢谢。
If your desired output is the string "abc,pqr,xyz": 如果所需的输出是字符串“ 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... 如果您尝试获取数组[“ abc”,“ pqr”,“ xyz”]:您的代码很好...
%dw 2.0
output application/json
---
payload filter ($.a != "") map ($.a)
query: joinBy(payload.a filter $ !="", ',')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.