我正在使用Anypoint Studio 6.1和Mule 3.8.1。
我有一个来自CSV文件的布尔字段,我想添加代码来清理数据,例如转" Y","是"变为true或以其他方式将其设置为false。
如果字段有值,我只希望代码能够工作。如果它是''如果填充然后清理数据我想忽略它。我认为添加一个when语句将是答案,但它在预览中会出错。我该如何进行有条不紊的检查?
Dataweave代码:
(payload filter $$ > 2) map ((payload01 , indexOfPayload01) -> {
({
isPaid: true
}
when payload01.balanced != ''
and ((lower payload01.balanced == 'yes'
or (lower payload01.balanced) == 'y'
or (lower payload01.balanced ) == 'true')
otherwise {
isPaid: false
})
})
答案 0 :(得分:0)
Please use below code snipped of Data Weave:
(payload filter $$ > 2) map ((payload01 , indexOfPayload01) -> {
({
isPaid: true when ((payload01.balanced != '')
and ((lower payload01.balanced) == 'yes')
or ((lower payload01.balanced) == 'y')
or ((lower payload01.balanced ) == 'true')) otherwise false
})
答案 1 :(得分:0)
(payload filter $$ > 2) map ((payload01 , indexOfPayload01) -> {
({
isPaid: true
}
when payload01.balanced?
and ((lower payload01.balanced == 'yes'
or (lower payload01.balanced) == 'y'
or (lower payload01.balanced ) == 'true')
otherwise {
isPaid: false
})
})
尝试以上操作。