我们的 Dynamics CRM 系统导出一个包含布尔元素的实体。元素可以具有的值是:true、false 和 null。如果不知道元素是否为秘密,则使用空值。例如 Dynamics 将导出以下 xml:
<SecretPhone>true</SecretPhone>
<SecretEmail>false</SecretEmail>
<SecretAddress i:nil = "true">
然后,当 BizTalk 使用带有 jsonencoder 管道的 SB 消息适配器将其发送到 Azure Servicebus 中的主题时,结果如下:
{
"SecretPhone": true,
"SecretEmail": false,
"SecretAddress": ""
}
我本来希望 null 布尔值是 null 而不是空字符串:
{
"SecretPhone": true,
"SecretEmail": false,
"SecretAddress": null
}
我尝试通过以下方式映射到目标 xml
<SecretAddress i:nil = "true" /> 映射到 <SecretAddress />
这导致 json 中的空字符串。(SecretAddress: "")
我也尝试像这样映射它:
<SecretAddress i:nil = "true"> 映射到 <SecretAddress i:nil = "true" />
但这会导致更奇怪的json
"SecretAddress": {
"@nil": "true"
},
我们正在使用 BizTalk 2020 CU3。Sandro Pereira 构建了一个自定义的 JsonEncoder 管道组件,它可以覆盖内置的 JsonEncoder,所以也许我需要使用它。我现在的解决方法是将 null 布尔值映射为 false,但这会改变发送到目标系统的数据。
将 null xml boolean 值 jsonencode 为 null json 值的任何其他方法?