Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XML TO JSON conversion in SOA 12c

User_O79WSMay 26 2019 — edited May 28 2019

Hi ,

I am going through exact same requirement specified in    .

I am exposing a REST bpel which has input and output variable as JSON Object . After converting the json input object to xml  ,I am hitting an external service which gives output in xml format .

Output from external service is something like

<?xml version="1.0" encoding="UTF-8"?>

<root>

<return>

<response>1234</response>

<responseCode>CITY,India</responseCode>

<responseMessage>Success ABC</responseMessage>

</return>

</root>

Now when i try to  assign the invoke output variable(xml) to  a JSON object ,I am getting JSON object as

{"return": {

   "response": [{"$": 1234}],

   "responseMessage": [{"$": "Success ABC"}],

   "responseCode": [{"$": "CITY,India"}]

}}

But i am expecting my JSON object to be something like

{"return": {

   "response": 1234,

   "responseMessage": "Success ABC",

   "responseCode": "CITY,India"

}}

from the other post ,I understand using JAVA script or assign we can get values form json even if $(dollar) is available using  following expression.

myObj.return["response"][0]["$"] returns 1234

myObj.return["responseMessage"][0]["$"] returns Success ABC

myObj.return["responseCode"][0]["$"] returns CITY, India

My requirement is to give the output as JSON  in correct format .

please find the sample project (12.2.1.3.0)in below link.

https://drive.google.com/drive/folders/1XtQARfrNOL8P5kQHRfUYIpU3ICD02Xxb

This project is currently producing output as

{

    "return": {

        "response": [

            {

                "$": 1234

            }

        ],

        "responseMessage": [

            {

                "$": "Success"

            }

        ],

        "responseCode": [

            {

                "$": "City,India"

            }

        ]

    }

}

But if any of you experts can help me or  tweak this project to produce exact same JSON response as I expect ,it would be really great.

Your help is greatly appreciated,since I am trying this for the first time. Thanks to all the experts in advance for your kind help.

Comments
Post Details
Added on May 26 2019
2 comments
3,094 views