BizTalk2013 R2 - JSON Encoder "Object reference not set to an instance of an object" RRS feed

  • Question

  • Hi All,

    I am trying to convert an xml to JSON format.  Using the sample here, I created a Send pipeline component and dropped the out-of-the-box JSON Encoder into the Encode section.  I tested this pipeline by:

    1. Create a receive port and a receive location using the File Adapter and the PassThruReceive

    2. Create a send port that receives a message from the above receive port via the File Adapter and my custom JSON send pipeline.

    3. Submit an XML file

    For some reasons BizTalks errors out with below text.

    "Source: "JSON encoder" Send Port: "SendPort1"Object reference not set to an instance of an object".

    Has anyone experienced this?  Thanks.

    Tuesday, February 10, 2015 3:25 AM

All replies

  • Can you confirm that the XML hitting your JSON encoder is valid XML? Are you able to open the source in an Internet Explorer? Also can you post your sample XML here?

    Morten la Cour


    I see now there is a stupid encoding error in the XML sample in my blog:


    <Order xmlns=”http://blogdemo.com/schemas/v10″&gt;


    <Order xmlns=”http://blogdemo.com/schemas/v10″>

    Morten la Cour
    • Edited by la Cour Tuesday, February 10, 2015 8:21 AM
    Tuesday, February 10, 2015 8:18 AM
  • Hi,

    Try specifying the Root Node and Root Node Namespace in the properties of the JSON decoder.



    Tuesday, February 10, 2015 11:09 AM
  • Hi la Cour Vertica, the XML is valid and I'm able to load the xml in IE. Below is the content of my test xml file.

    <ns0:EnrollmentApplicationEvent xmlns:ns0="http://www.abc.edu/CRM/EnrollmentApplicationEvent/20130803" xmlns:ns4="http://www.abc.edu/CRM/Address/20130614" xmlns:ns3="http://www.abc.edu/CRM/EmailAddress/20130614" xmlns:ns1="http://www.abc.edu/CRM/Enrollment/20130614" xmlns:ns2="http://www.abc.edu/CRM/Phone/20130614">
      <ProcessData xmlns="http://www.abc.edu/CRM/EnrollmentApplicationEvent/20130803">
       <Enrollment xmlns:b="http://www.abc.edu/ApplicationEvents/Schemas/ApplicationEvent/20101012" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.abc.edu/CRM/Enrollment/20130614">
        <Addresses xmlns:a="http://www.abc.edu/CRM/Address/20130614">
          <a:Address2 i:nil="true"/>
          <a:City i:nil="true"/>
          <a:Country i:nil="true"/>
          <a:County i:nil="true"/>
          <a:Longitude i:nil="true"/>
          <a:PostalCode i:nil="true"/>
          <a:State i:nil="true"/>
          <a:StateOrProvinceName i:nil="true"/>
        <EmailAddresses xmlns:a="http://www.abc.edu/CRM/EmailAddress/20130614">
          <a:Type i:nil="true"/>
        <HighSchoolGradType i:nil="true"/>
        <HighSchoolName>18 - 20 Program</HighSchoolName>
        <IsUsCitizen i:nil="true"/>
        <ManufacturerProgramOfInterests xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
        <MiddleName i:nil="true"/>
        <MilitaryBaseName>1  111th  Aviation Support</MilitaryBaseName>
        <MilitaryReleaseMonth i:nil="true"/>
        <MilitaryReleaseYear i:nil="true"/>
        <NameSuffix i:nil="true"/>
        <NameTitle i:nil="true"/>
        <PhoneNumbers xmlns:a="http://www.abc.edu/CRM/Phone/20130614">
          <a:Extension i:nil="true"/>
          <a:Extension i:nil="true"/>
          <a:Extension i:nil="true"/>
          <a:Extension i:nil="true"/>
        <PreferredMethodOfContact i:nil="true"/>
        <Program i:nil="true"/>
        <Ssn i:nil="true"/>

    • Edited by AnSDE007 Tuesday, February 10, 2015 5:08 PM
    Tuesday, February 10, 2015 4:48 PM
  • Hi Daniel - I did not see Root Node and Root Node Namespace listed.  Below are the properties that are listed for JSON encoder component.

    • Assembly
    • Description
    • Managed
    • Path
    • Remove Outer Envelope
    • Type

    • Edited by AnSDE007 Tuesday, February 10, 2015 4:50 PM
    Tuesday, February 10, 2015 4:50 PM
  • Hi, I'm encountering the same problem, did you ever find a resolution to this. I've tried the same basic setup and get the same error. I'm using Itineraries, so not sure if that's causing an additional error or not.
    Thursday, November 5, 2015 2:16 AM
  • Nolan - No, I did not find a resolution.  Luckily it was just a POC (Proof of Concept).
    Thursday, November 5, 2015 3:34 PM
  • Hi,

    JSON encoder dont have RootNode & Namespace Properties. I'm also facing the same problem.Please reply if you find solution for above problem

    • Proposed as answer by Sandesh Sahane Friday, December 18, 2015 10:57 AM
    • Unproposed as answer by Sandesh Sahane Monday, December 21, 2015 11:43 AM
    Tuesday, December 8, 2015 5:43 PM
  • Hi , 
    Convert your xml to JSON format, for that you will have to create JSON schema.Try using link for conversion: http://codebeautify.org/xmltojson 

    -Create .Json file from above link & while creating JSON schema from biztalk uses this file.It will create JSON schema for your xml.
    -Now do transformation from your xml->JSON schema & send transformed output to  send port which uses custom JSON send pipeline.

    My observation is,if you are sending special namespaces in xml,for JSON encoder it's hard to understand the namespaces you are sending and could not convert it to JSON format.
    If you have plain xml without any namespace u can easily convert it to JSON format without using JSON schema but if you have namespaces for your xml you will have to use JSON schema.

    Monday, December 21, 2015 11:42 AM