none
JSON encoder difference between BizTalk versions RRS feed

  • Question

  • Hi,

    In Biztalk 2013 we receive the following XML tags:

    <Contact />
    <CodesArray />

    We run in through a JSON encoder pipeline and it creates the following which is correct:

    "Contact": null,
    "CodesArray: null,

    Then we migrated this solution to BizTalk 2016 and offered the same XML and got the following result:

    "Contact": "",
    "CodesArray: "",

    How can we get the same result as we had in BizTalk 2013 which is the correct way of showing a empty JSON node.

    Friday, November 1, 2019 10:16 AM

All replies

  • Try modifying your map, check to see with Logical existence functoid for that field. It should provide the output as you are expecting

    RH

    Friday, November 1, 2019 10:39 AM
  • Thats an option but then i have to map every element to a logical existence functoid first, while this issue gets created by the JSON encoder of biztalk 2016.
    Friday, November 1, 2019 12:06 PM
  • See also this StackOverflow question JSON encoder generating JSON message adding empty quotes characters in BizTalk 2016

    As per my answer there, 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.

    Sunday, November 3, 2019 5:49 PM
  • Unfortunately XSD:nul="true" doesnt work. 

    I discovered that its not the JSON Encoder thats causing the issue but its the map that makes the change to the output.

    I made a simple test solution where i place in a XML and convert it to JSON with a JSON encoder component.
    My input XML, where i have 1 element with a self closing tag and a element with a start and closing element without data in it:

    <ns0:Root xmlns:ns0="http://BizTalk_Server_Project1.Schema1">
      <Customer>
        <CustomerMail>CustomerMail_0</CustomerMail>
        <CustomerName>CustomerName_0</CustomerName>
      </Customer>
      <Customer>
        <CustomerMail/>
        <CustomerName>CustomerName_0</CustomerName>
      </Customer>
      <Customer>
        <CustomerMail></CustomerMail>
        <CustomerName>CustomerName_0</CustomerName>
      </Customer>
    </ns0:Root>

    The result without any mapping:

    {
      "Root": {
        "Customer": [
          {
            "CustomerMail": "CustomerMail_0",
            "CustomerName": "CustomerName_0"
          },
          {
            "CustomerMail": null,
            "CustomerName": "CustomerName_0"
          },
          {
            "CustomerMail": "",
            "CustomerName": "CustomerName_0"
          }
        ]
      }
    }

    The second node gives the result i want, so a self closing tag does work with the JSON encoder. 

    Then i made a simple 1 on 1 map and send the same input XML. The result:

    {
      "Root": {
        "Customer": [
          {
            "CustomerMail": "CustomerMail_0",
            "CustomerName": "CustomerName_0"
          },
          {
            "CustomerMail": "",
            "CustomerName": "CustomerName_0"
          },
          {
            "CustomerMail": "",
            "CustomerName": "CustomerName_0"
          }
        ]
      }
    }

    This time the second node has the same result as the third one. Even when i makes the elements nillable=true it doesnt work.

    What's also weird i that when i apply the mapping and use the XMLTransmit pipeline instead of the JSON pipeline i get the same end result so the second node also had a closed tag just like the input file.

    <?xml version="1.0" encoding="utf-16"?>
    <ns0:Root xmlns:ns0="http://BizTalk_Server_Project1.Schema2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    	<Customer>
    		<CustomerMail>CustomerMail_0</CustomerMail>
    		<CustomerName>CustomerName_0</CustomerName>
    	</Customer>
    	<Customer>
    		<CustomerMail/>
    		<CustomerName>CustomerName_0</CustomerName>
    	</Customer>
    	<Customer>
    		<CustomerMail/>
    		<CustomerName>CustomerName_0</CustomerName>
    	</Customer>
    </ns0:Root>


    • Edited by Ronald Veenman Tuesday, November 5, 2019 9:54 AM Extra info
    Tuesday, November 5, 2019 9:40 AM