1

My XML message

<ns0:rootNode xmlns:ns0="http://project.Schemas.rootNode">  
  <bitmap></bitmap>
</ns0:rootNode>

after json encoder converting, below is the

{
      "bitmap": ""
}

but I'm expecting in below format

{
      "bitmap": null
}

For some reason BizTalk 2013 R2 able to convert it as expected, but BizTalk 2016 is not able to do the same.

I have tried by making bitmap to string, boolean and datetime datatypes, but not able to make it.

Is there any suggestions or custom pipeline is the only one option I have?

Dijkgraaf
  • 9,324
  • 15
  • 34
  • 48
Software Enginner
  • 587
  • 1
  • 11
  • 40

2 Answers2

3

Here's the current behavior of Biztalk 2016 JSON Encoder

Input XML:

<test>
    <a></a>
    <b>test</b>
    <c>NULL</c>
    <d/>
</test>

Output:

{
  "test": {
    "a": "",
    "b": "test",
    "c": "NULL",
    "d": null
  }
}

In order to generate json null values, elements should be in self closing tag form

Ed Bangga
  • 11,622
  • 4
  • 10
  • 29
0

So they fixed an issue that existed in BizTalk 2013 R2 as per my blog post, 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.

If you want to have it null, maybe you need to set the xsd nillable property to true on that field in the schema and have xsi:nil="true" set in the payload.

Other than that, you would have to do the opposite of the fix we had to implement for BizTalk 2013 R2.

Dijkgraaf
  • 9,324
  • 15
  • 34
  • 48