· Nov 15, 2022

Transform JSON as VDOC


Is there a way to read JSON and transform it (in DTL) by using a VDOC of this JSON (without transform it to internal message) like I can do with HL7 or XML?

If it possible, I guess that I should have a schema of the JSON so the second question is how to build a schema for JSON and load it to the IRIS?


Thanks, Ori.

Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.2 (Build 368U)
Discussion (2)2
Log in or sign up to continue

Hi @Ori Tsarfati!

Recently, I had a similar requirement in a personal project and found JSON2Persistent in OpenExchange from @Michael Braam.

I don't know if this is exactly what you need, but using this tool you can transform an ordinary JSON into in a set of persistent IRIS classes which could be used in DTLs.

For instance, I took this FHIR resrouce example and save it to a file.

JSON input

Then I exctracted a set of persistent classes organized in a package called tmp.FHIRObservationSchema from that file using JSON2Persistent, like this:

$$$TOE(sc, ##class(ISC.SE.Tools.JSON).GenerateClasses("/tmp/file.json", "tmp", "FHIRObservationSchema", 0, 1, "crk", 1))

After that, I was able to create a DTLs using the schema created from the FHIR resource JSON:

DTL (Code)

So, I create a method to test it:

DTL test method

And got this output: