我将让代码进行解释。
Dataweave给出错误:
无法解决何时引用
无法解决其他参考
输入消息:对象数组。尽管我在这里只给出了1个对象。
[{
"Field1" : 12345,
"field2" : 10
}]
%dw 2.0
output application/json
---
payload map {
"test" : $.Field1 when $.field2 >= 1 otherwise ""
}
Nadeem DW 2.0中没有<expression> when <condition> otherwise <expression>
。请改用if (condition) <then_expression> else <else_expression>
。
所以您的代码如下:
%dw 2.0
output application/json
var data = [{
"Field1" : 12345,
"field2" : 10
}]
---
data map {
test : if ($.field2 >= 1) $.Field1 else ""
}