Search code examples
c#biztalkbiztalk-2013

BizTalk 2013 - decode JSON array


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?


Solution

  • 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.