BizTalk JSON Schema Wizard: Error in JSON Instance File.XMLNodeConverter can only convert JSON that begins with an object

This week while trying to use the BizTalk Server 2016 JSON Schema Wizard to generate an XML schema from a specific JSON file to be sent to a Logic App I got the following error:

Error in JSON Instance File.XMLNodeConverter can only convert JSON that begins with an object. Path ‘’, line 1, position 1.

The JSON file had the following format:

[
  {
    "IntID": 208,
    "ItemLogID": 14255826,
    "Step": "IN",
    "BusinessUnit": "TST",
  },
  {
    "IntID": 209,
    "ItemLogID": 14257419,
    "Step": "IN",
    "BusinessUnit": "TST",
  }
]

Basically, I’m trying to send a list of “objects” that in my case are Locks, to be processed.

Cause

The cause of this “problem” is that a JSON array of objects, it may not make sense in a BizTalk Server XML world as Morten la Cour very well written in this forum. At that sentence, I will add: “at it his being done today”. Because with a few improvements could be smarter and support this type of messages.

Why? The BizTalk JSON Schema Wizard is a simple and “stupid” converter, it will ask only for you to provide a root node and a namespace that it will add to the XML Schema and the XML JSON representation because it will require that information to be able to uniquely identify this type of message.

But it will not understand what is a “not identified” object array because it needs to give it a Record name in the XML equivalent.

So, that means that it will not support JSON arrays?

No, it will support JSON arrays if you provide a field name to that array, i.e., instead of having:

[
…
]

You should have:

{
   "field name": [
   …
   ]
}

Solution

If you don’t have the control over that JSON message, you may need to create a custom pipeline component to add or remove this field name that will identify the array in the XML equivalent message.

If you have control over the structure of the JSON message the simple way is to modify the structure of the message to include a field name to identify the array. Lucky it was my case, so I modify the original structure descrived above to be:

  {
    "locks": [
    {
      "IntID": 208,
      "ItemLogID": 14255826,
      "Step": "IN",
      "BusinessUnit": "TST",
    },
    {
      "IntID": 209,
      "ItemLogID": 14257419,
      "Step": "IN",
      "BusinessUnit": "TST",
    }
  ]
}

Now, if I try to run the BizTalk JSON Schema Wizard against this message it will be able to create the JSON Schema.

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

6 thoughts on “BizTalk JSON Schema Wizard: Error in JSON Instance File.XMLNodeConverter can only convert JSON that begins with an object”

  1. Hello .

    Yes , i have faced this issues earlier and created a custom PC to add the root array object name.

    also there was one more issues. if there is a space in a json tagname , then the JSON decoder also will not work. exa “Int ID” .as there is a space between Int and ID.

    Thank you

  2. My biggest disappointment with the JSON decoder is that it *requires* you to specify a root node in the pipeline properties but isn’t smart enough to recognize when the JSON already contains a “root” and doesn’t need yet another one added around it. There doesn’t seem to be a sane, easy way to accept a message like this without having an additional, completely unnecessary containing tag in your XML schema.

    {
    “person”: {
    “name”: “Todd”,
    “favoriteColor”: “red”
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

BizTalk360
BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More
Serverless360
Azure

Manage and monitor serverless
components effortlessly

Learn More
Atomicscope
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top