Using BizTalk 2013 R2 to transform an XML message element to a JSON array

Posted: September 25, 2015  |  Categories: BizTalk Uncategorized

I wanted to know whether the out of the box  JSON encoder pipeline component creates an JSON array  if there is only one repeating XML fragment. One of my colleagues found with BizTalk 2013 he had to add an array attribute to the XML to force the creation of a JSON array (https://connectedcircuits.wordpress.com/2014/03/27/sending-json-messages-from-a-biztalk2013-adaptor/).

I created a test schema shown below and deployed it to my run time.

image

I created this message and consumed it with a receive location that was configured with  passthrureceive location.

<ns0:Repeater xmlns:ns0=”http://JSONTest.Repeater”>
<Repeat>Repeat_0</Repeat>
</ns0:Repeater>

The XML message was then processed on a send port with a pipeline that only contained the JSON encoder pipeline component. Voila! I got the correct output shown below;

{
“Repeater”: {
“Repeat”: [
“Repeat_0”
]
}
}

Thanks Microsoft this has saved me a lot of extra work that i had to do in BizTalk 2013.

turbo360

Back to Top