BizTalk XML To JSON Array conversion

We have all the functionality we need to work with JSON messages in Microsoft BizTalk Server. But sometime we need to make some tweaks at the Schema level based on the requirement we have.

Last week we had a requirement to send a JSON Message to the end system with a repeating record as an Array. When the values repeated for that record  the message was send to the End System as an array.

The problem occurred when we had a non-repeating record  and the end system still expected an array bracket [] to be sent across.

Let’ try to understand the scenario with an example –

  • Incoming XML has repeating record.
  • Outgoing JSON ( Populated as an array – array bracket [] as marked in Red, because of incoming repeating record )
  • We are using a inbuilt XML to JSON Encoder on our send side with RemoveOuterEnvelope property set to true.


Now if we receive only a single incoming record from Source than the out .Json is not  populated with an array bracket [] since it’s a non-repeating record. Screenshot as below.

And the End-System does require us to send an array bracket [] in the .Json message because it’s an array field on their end.


So how can we make sure that irrespective of records, we must always send an array sticks to the end-system .

The way to handle this is to have the same Min and Max occurrence value for HeaderData record  in the End-System schema defined in BizTalk. After making the necessary changes and running the message again from BizTalk we have the necessary array bracket [] populated.


We could have also solved this by creating a pipeline component, but that would not have been the best possible solution. The behavior of BizTalk was normal in this case but when you are using the in-build function of XML to JSON conversion the min and max occurrence of schema plays a vital role.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s