简体   繁体   English

如何循环或迭代数组列表,然后连接 Dataweave 中的值

[英]How to loop thru or iterate an array list and then concatenate the values in Dataweave

I have an input payload [id, name].我有一个输入有效载荷 [id, name]。 Based on this input, I want to loop through each value in the array and form a where clause for my select statement.基于这个输入,我想遍历数组中的每个值,并为我的 select 语句形成一个 where 子句。

Input:输入:

{
"column": ["id","name"]
} 

Expected Output:预期 Output:

"id == '123' and name == 'abc'"

With one column I am able to do, but with multiple columns how to iterate and then concatenate?用一列我可以做到,但是用多列如何迭代然后连接?

Assuming you lookup values from another array, you could do something crude like this.假设您从另一个数组中查找值,您可以像这样粗略地做一些事情。

%dw 2.0
output application/json
var values = [2,"test"]
---
payload.column map 
{ 
    a: $ ++ " == " ++ "'" ++ values[($$)] ++ "'"
}.a  joinBy " and "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM