Skip to Content
0
Jun 08, 2016 at 05:55 AM

JSON to XML converter unexpected array behavior

345 Views

Hi all

In one of my transaction I receive a JSON input like the example below:

{
     "scenario": 1,
     "matFrom": "aa",
     "matTo": "bb",
     "batchFrom": "a1",
     "batchTo": "b1",
     "quantityTo": "0.08",
     "pallets":[
          "11",
          "22",
          "33"
     ]
}

I use the JSON to XML converter action block to generate the XML, but my 'pallets' array disappears!

I would expect my array to be converted to an XML list of element tags?!

<?xml version="1.0" encoding="UTF-8"?><root>
     <scenario>1</scenario>
     <matFrom>aa</matFrom>
     <matTo>bb</matTo>
     <batchFrom>a1</batchFrom>
     <batchTo>b1</batchTo>
     <quantityTo>0.08</quantityTo>
     <pallets/>
</root>

If I change my JSON array to an array with objects like this:

{
     ...
     "pallets": [
          {
               "nr": "11"
          },
          {
               "nr": "22"
          },
          {
               "nr": "33"
          }
     ]
}

Then this will convert to an XML list of elements like this:

<?xml version="1.0" encoding="UTF-8"?><root>
    <scenario>1</scenario>
    <matFrom>aa</matFrom>
    <matTo>bb</matTo>
    <batchFrom>a1</batchFrom>
    <batchTo>b1</batchTo>
    <quantityTo>0.08</quantityTo>
    <pallets>
        <element>
            <nr>11</nr>
        </element>
        <element>
            <nr>22</nr>
        </element>
        <element>
            <nr>33</nr>
        </element>
    </pallets>
</root>

Is this a bug or is this normal behaviour?

I'm running this on SAP MII v.15.0 SP2 Patch 4.