Question
prashanth ponugoti · Nov 24

How to convert xml string to JSON in Object SCRIPT

Hi All,

I am working in Heath Share Heath Connect Integration.

I have a requirement to change SOAP call to REST call in integration. For SOAP call already payload is ready in XML string. and Working fine.

Now I need to make REST API call instead of existing SOAP call.

I have created REST Business Operation and ready to Call it from Business Process.

Here I should not change any Transformation in Business Process , only change  in Operation invocation

Only change is existing SOAP Operation expecting XML String , new REST Operation is expecting JSON.

How can I convert existing XML String to JSON by calling any Utility function in Object Script.

Thanks

Prashanth

 

Product version: IRIS 2020.1
10
1 0 5 117
Log in or sign up to continue

Just another strong argument for embedded Python
Or calling Py over $ZF() or CPIPE  for older versions

The code to convert XML to JSON is quite simple, just two lines.
The xmltodict. parse() method will convert the XML to a python object
that can then be converted to JSON.

How to convert XML to JSON in Python – Step by Step guide
(found by Google)

 

If your message class is the one you want to convert just extend both XML and JSON ? Extends (%Persistent, %XML.Adaptor, %JSON.Adaptor) And (assuming your schemas line up): Set tSC = tMsg.%JSONExportToString(.tJSONMsg)

Sorry, formatting messed up and I can't seem to edit... If your message class is the one you want to convert just extend both XML and JSON ? Extends (%Persistent, %XML.Adaptor, %JSON.Adaptor) And (assuming your schemas line up): Set tSC = tMsg.%JSONExportToString(.tJSONMsg)

Extend your Message class with either Extends (%RegisteredObject, %JSON.Adaptor, %XML.Adaptor) or Extends (%Persistent, %XML.Adaptor, %JSON.Adaptor) .If your schemas line up then you can use below command to convert your message to json.

set tSC = tMessageObject.%JSONExportToString(.jsonEvent)