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.
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
In what version was that?
I’m asking that because I faced some issues in the past but the FP solved part of them
BizTalk 2016
Do you have installed BizTalk Server Feature Pack 2 in your DEV machine?
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”
}
}