Skip to Content
1
May 11, 2015 at 05:07 PM

XML to JSON - force Square brackets via SAP PI

1388 Views

Hi,

One of the 3rd party systems that we integrate to needs some JSON objects to be array objects irrespective of whether one or more values are passed to it. Does SAP PI REST Adapter support this? If so how? Are there any tweaks that can be done to achieve this?

{

"Items": [

{

"KDS": [

{

"DimRole": "Prod",

"DimLvl": "PROD_DES",

"DimVal": "XXOOIIRP Fibre"

}

],

"Tag": "amendments"

}

]

}

In the above Json, the object KDS is needed by the target system as an array. SAP PI by default looks at the number of KDS that are passed and if there are only 1 set, then it puts only {} around the value for the object. The target system requires that SAP PI always puts the {} as well as the [] for the value of the object.

SAP PI correctly puts both the {} and the [] around the values in case more than one KDS sets are passed and this is processed correctly by the target application.

Please help with a solution for this.