英文:
Map empty string in destination schema Biztalk 2016 to JSON
问题
有时源架构中的某些元素没有任何数据,并且这些元素以自封闭标签的形式出现,如下所示:
<element/>
在目标架构中,映射的元素以自封闭标签的形式存在,但是当使用BizTalk提供的JSON编码器将XML转换为JSON时,所有带有自封闭标签的元素都会得到一个值,如下所示:
"element":null
相反,我希望这个元素不包含任何值,甚至不包含null,因为目标系统无法处理它。有没有办法可以阻止在不包含任何数据的元素中添加null值?
附言:这是一个简单的一对一映射。
尝试使用脚本 functoid 传递空引号,但在JSON中这也被转换为null。
英文:
Sometimes some elements in the source schema does not have any data and these elements appear in a self closing tag like
<element/>
And in the destination schema the mapped element is present with a self closing tag, but when the XML gets converted into JSON by using JSON encoder that comes with BizTalk, all the elements with self closing tag gets a value like
"element":null
Instead I want this element to does not contain any value not even null, because the destination system can't handle it. There is anyway by which I can stop these null getting added in the elements that do not contain any data?.
P.S: It is a simple one to one mapping.
Tried using scripting functoid to pass empty quotes, but this is also getting converted into null in JSON
答案1
得分: 0
基本上,解决方案是一个管道组件,用空字符串替换Null。
我还在BizTalk 2013 R2已知的错误、问题和怪癖中发表了博客
> 问题: BIZTALK JSON编码器将XML中的空格更改为JSON中的Null
> 详细信息: 如果您使用JSON编码器并且有一个空元素,它会在JSON负载中变成Null。
> 更多详细信息: REST JSON圣诞谜题
> 解决方法: 使用BRE管道并将消息正文中的字符串“: null”替换为字符串“:”(最初的概念来自REST JSON圣诞谜题 - 解决方法)。
> 注意: 以上解决方法会意外地添加BOM。这可能会导致某些系统出现问题。
英文:
See REST JSON Christmas Puzzle – Work around
Essentially the solution is a Pipeline Component to replace the Null with an empty string.
I also blogged about it in BizTalk 2013 R2 known bugs, issues & quirks
> ISSUE: THE BIZTALK JSON ENCODER CHANGES BLANKS IN XML TO NULL IN JSON
>Details: If you use the JSON Encoder and have a element that is empty, it becomes a null in the JSON payload.
>More Details: REST JSON Christmas Puzzle
>Work Around: Use the BRE Pipeline and do a Replace the string “: null in the message body with the string “:”” (initial concept from REST JSON Christmas Puzzle – Work around).
>Note: The above work around has an unintended side effect that it causes a BOM to be added. This may cause issues with some systems.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论