“何时有其他情况”的问题

问题描述 投票:0回答:1

我将让代码进行解释。

Dataweave给出错误:

无法解决何时引用

无法解决其他参考

输入消息:对象数组。尽管我在这里只给出了1个对象。

[{
    "Field1" : 12345,
    "field2" : 10
}]
%dw 2.0
output application/json
---
payload map {
"test" : $.Field1 when $.field2 >= 1 otherwise ""
}
mule mule-studio dataweave mulesoft mule-esb
1个回答
2
投票

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 ""
}
© www.soinside.com 2019 - 2024. All rights reserved.