mule - “何时和其他”条件的问题
问题描述
我会让代码做解释。
Dataweave 给出错误:
无法解析何时参考
无法解决其他参考
输入消息:对象数组。虽然我在这里只给出了 1 个对象。
[{
"Field1" : 12345,
"field2" : 10
}]
%dw 2.0
output application/json
---
payload map {
"test" : $.Field1 when $.field2 >= 1 otherwise ""
}
解决方案
<expression> when <condition> otherwise <expression>
Nadeem在 DW 2.0中没有。改为使用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 ""
}
推荐阅读
- c - 使用 O_DIRECT 打开的文件中的 seek() 和 read()
- python - 为什么使用具有更大验证数据集的 Google colab TPU 需要更长的时间?
- python - Python循环导入,没有属性的错误
- vb.net - 如何从 OLE DB 查询中获取数据
- reactjs - React useEffect 警告:无法在未安装的组件上执行 React 状态更新导致 switch 语句呈现错误的组件
- haskell - 如何在 Haskell 中编写多参数函数(可变数量的参数)
- python-3.x - Python 3:使用理解返回空列表而不是以元音开头的单词列表
- flutter - 从 Flutter 中的 For 循环创建列表
- c# - 面板内的必填字段导致验证错误
- class - SwiftUI - 将用户位置信息从 LocationManager 传递到另一个类