问题描述
我有以下输入
输入:
JSON:
{
"abc": ""
}
预期输出:
XML:
<abc xsi:nil="true"/>
使用的数据织法:
%dw 2.0
output application/xml
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
(if(payload.abc == "")
(abc @(xsi#'nil': true):{})
else
null)
I am getting an error. Please help me with this
解决方法
定义dataweave输出时,可以使用'writeNilOnNull'writer属性:
%dw 2.0
output application/xml writeNilOnNull=true
---
payload
请注意,此属性只会为null属性(在您提供的示例中,空字符串不为null)设置nil。
以下屏幕截图显示了此行为: