Published on InterSystems Developer Community (https://community.intersystems.com)

Home > How to convert DTL output to JSON

Question
prashanth ponugoti · Jan 6, 2022

How to convert DTL output to JSON

Hi Friends ,

We have requirement to convert source hl7 message to target json message using dtl.

Currently I have created persistent cls for json and completed the dtl.

DTL giving output as json equivalent xml.

Now how to convert DTL result xml object to json?

set oStream = ##class(%Stream.GlobalCharacter).%New()
set json = pResDTLresponseXml.%ToJSON()
set tSC = ##class("%ZEN.Auxiliary.altJSONProvider").%WriteJSONFromObject(pResDTLresponseXml,.json)
set tSC = oStream.Write(json)
if $$$ISERR(tSC) $$$LOGERROR("Error convert dynamic object to JSON stream: "_$System.Status.GetOneStatusText(tSC))
$$$TRACE("Transformed json: "_json)

Thanks,

Prashanth

#DTL #HL7 #Caché
Product version: Caché 2017.1

Source URL:https://community.intersystems.com/post/how-convert-dtl-output-json