Reputation: 579
Using BizTalk 2013 it is straightforward to create a XSD schema from a JSON entity and use the JSON decoder in a receive pipeline to convert a JSON message into XML.
However when the external system sends an array of JSON entities enclosed with the
array [] syntax
the JSON decoder falls over with error
XmlNodeConverter can only convert JSON that begins with an object
In an attempt to fix this I tried to create a new XSD schema using the JSON Schema Wizard and an example of the JSON array data - however the wizard could also not recognise the array.
How can the JSON decoder in a receive pipleline be configured to decode an array of objects?
Upvotes: 3
Views: 2423
Reputation: 336
A working solution is presented here: Error in JSON Instance File.XmlNodeConverter can only convert JSON that begins with an object
Be aware, though, that the above blog post contains an error. As stated in this thread BizTalk - Json response from a rest service
the code uses a formatting string in a resource file that should be exactly {{"{0}":{1}}}
, with the correct double quote characters.
Also, the pipeline configuration in the second step (Decode - Component(2): JSON Decoder) has to exactly match the Biztalk XML schema root node name and root node namespace. The root node name in the first step can be whatever (I stuck with "List")
Upvotes: 1
Reputation: 424
One possible solution would be to create your own custom pipeline component which extends the JSON decoder. You can use this to prepare the JSON data by modifying it to be a single object, or by splitting it into a number of objects and sending each one individually through the underlying JSON decoder.
Microsoft have published an example of how to do a similar task with the flat file disassembler which can be found in the samples that come with the BizTalk SDK
The logic is the same so you should be able to adapt these steps to extend the JSON decoder.
Upvotes: 2