Question
· Jan 24, 2023

JSON Object

Dear Friends

Please help me to create  %ZEN.proxyObject same in below example:

 

{

    "dynamicLinkInfo": {

        "domainUriPrefix""link.example.com",

        "link""https://www.examplelink.com"
    },

    "suffix": {

        "option""SHORT"
    }

}

 

My Code

   

 // body
    set BodyObject=##class(%ZEN.proxyObject).%New()
    set dynamicLinkInfo=##class(%ZEN.proxyObject).%New()
    set suffix=##class(%ZEN.proxyObject).%New()
set DataObj=##class(%ZEN.proxyObject).%New()
set Data2Obj=##class(%ZEN.proxyObject).%New()
Set DataObj.domainUriPrefix= "link.example.com"
Set DataObj.link= url
Set Data2Obj.option= "SHORT"
Set dynamicLinkInfo.dynamicLinkInfo= DataObj
Set suffix.suffix= Data2Obj
set BodyObject = dynamicLinkInfo
Product version: IRIS 2022.2
Discussion (2)1
Log in or sign up to continue

Since you're using IRIS 2022.2 I would really suggest you use %DynamicObject:

https://docs.intersystems.com/iris20222/csp/docbook/Doc.View.cls?KEY=GJS...

   set dynObject1 = ##class(%DynamicObject).%New()
   set dynObject1.dynamicLinkInfo = ##class(%DynamicObject).%New()
   set dynObject1.dynamicLinkInfo.domainUriPrefix = "link.example.com"
   set dynObject1.dynamicLinkInfo.link = "https://www.examplelink.com"
   set dynObject1.suffix = = ##class(%DynamicObject).%New()
   set dynObject1.suffix.option = "SHORT"