biztalkbiztalk-2016biztalk-mapperbiztalk-pipelines

Map empty string in destination schema Biztalk 2016 to JSON


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


Solution

  • 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.