Converting Json to xml implementation code RRS feed

  • Question

  • Hi 

    I am developing a biztalk applicaation in 2010.I have done an application which receives xml input and xml output.

    Now i need to convert it to json input and json output.

    I had completed some steps for that

    I pasted this into my function. But iam getting error in rootnode and jsonconvert. How should i include json convert reference into the project?

    • Edited by Suja Balan Wednesday, October 26, 2016 9:54 AM
    Tuesday, July 5, 2016 11:40 AM


All replies

  • Hi

    The sample code is downloadable from the blog you are following - author has shared a Github link . You can download it and build directly.

    For the issue,  you are missing references to the NewtonSoft.JSON libraries,  you can download it by searching for it online.

    Thanks Arindam

    Tuesday, July 5, 2016 11:50 AM
  • Saravana has what I think is a slightly more understandable description here:

    The root node is the top level Xml Element in an Xml Document.  That's all.

    The ESBT Add Namespace component is just that, it adds a namespace.  That's optional so focus on getting the JSON implementation working first.

    Tuesday, July 5, 2016 12:14 PM
  • Hi

    So RootNode is a property defined on the JsonToXmlConverter Pipeline component that is configurable after you build the solution. In Admin Console, after you deploy the pipeline, you will be able to provide a value for the RootNode property. It's value is loaded from the pipeline configuration at runtime as follows-

    void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog)
                object obj1 = PcHelper.ReadPropertyBag(propertyBag, "RootNode");
                if (obj1 != null)
                    Rootnode = (string)obj1;

    In your case, you have to provide a value of LOGIN to the RootNode property, after you deploy your custom pipeline. Note that JSON is just a collection of name-value pairs, but XML needs a Root XML node element, hence the need for such a property.

    Regarding the 2nd question-

    Apart from XML RootNode, you also need a Namespace to be specified for your XML message once it is converted from JSON - this is the XML namespace that you see in the LOGIN node. In this case, the author has used the ESB Add Namespace pipeline component that comes with the ESB Toolkit. Note that it is not a requirement to use the ESB Add Namespace pipeline component to add the namespace to your XML message. There are other/simpler ways to add a namespace to XML messages, where you don't have to install the ESB Toolkit.

    Some options are-

    Thanks Arindam

    Tuesday, July 5, 2016 12:25 PM
  • Not necessary to add the ESB Add Namespace component specifically, but there should be a custom pipeline component after the JsonToXML component that can add a namespace on XML messages(this will be the 2nd component in the DECODE stage). You may refer these samples that don't use the ESBT-

    Thanks Arindam

    Tuesday, July 5, 2016 12:31 PM
  • So is it necessary to add esb namespace.currently i have added pipeline component in decode and xml diassembler.

    No, but if you do, it must happen between the JSON Decoder and XmlDisassembler.

    Also, one point on the root node.  Technically, JSON does not require an equivalent of a Root Node but Xml does.  So, the popular JSON decoders have this property ensure an Xml compliant document is generated.

    Tuesday, July 5, 2016 12:48 PM
  • Is the pipeline component assembly signed and placed either in GAC or Pipeline Components folder in BizTalk installation directory?

    Thanks Arindam

    Tuesday, July 5, 2016 1:46 PM
  • This Wiki Article will answer all of you questions regarding pipeline component deployment:

    Of note, do not put the Assembly in the Pipeline Components folder.

    • Marked as answer by Angie Xu Monday, July 18, 2016 2:03 AM
    Tuesday, July 5, 2016 2:06 PM