"when and otherwise" 条件有问题
Problem with "when and otherwise" condition
我让代码来解释吧。
Dataweave 给出错误:
Unable to resolve reference of when
Unable to resolve reference of otherwise
输入消息:一组对象。虽然我在这里只给出了 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 ""
}
我让代码来解释吧。
Dataweave 给出错误:
Unable to resolve reference of when
Unable to resolve reference of otherwise
输入消息:一组对象。虽然我在这里只给出了 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 ""
}