Skip to Content

REST Receiver XML to JSON. Force Array (Square Bracket) at Top Level

Dear Experts,

I have to consume a JSON format REST web service from third party. They expect to have a square bracket (array) at the top level of the JSON request message. Currently the format that is produced from the REST Comm.Channel is something like this:

{
   "FLD1":"VAL1",
   "FLD2":"VAL2",
   "FLD3":"VAL3"
}

But they actually expecting a format something like this:

[{
   "FLD1":"VAL1",
   "FLD2":"VAL2",
   "FLD3":"VAL3"
}]

How to force the square bracket at the top level with the SAP PI REST Comm.Channel?

Thank you,

Regards.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 23, 2018 at 10:06 AM

    Hi Suwandi!

    There is no need to re-invent the wheel.

    Take a look at SAP Note: 2175218 - New Feature: Enhanced XML/JSON conversion capabilities

    and also at wonderful blog written by Vadim Klimov :

    https://blogs.sap.com/2016/01/13/rest-adapter-in-sap-pipo-enhanced-xmljson-conversion/

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 23, 2018 at 09:51 AM

    I found out this Adapter Module which probably could be used to force square bracket:

    https://blogs.sap.com/2015/03/18/jsontransformbean-part-2-converting-xml-to-json-content/

    Add comment
    10|10000 characters needed characters exceeded