Question
Sabit Issakhan · Nov 26, 2020

Set null

Hello! 

How to set null in variable? 

I need to create JSON like below:

{

"id":"1",

"Code": null

}

0
0 266
Discussion (3)0
Log in or sign up to continue

    set t={"id":"1","Code"2}
    write t.%ToJSON(),!
    
    do t.%Set("Code","","null")
    write t.%ToJSON()

%Set

Set Property Parameter %JSONNULL = 1

  Property Code As %String(%JSONNULL = 1);
Code = ""  >>> "Code":null
Code =$c(0)  >>> "Code":""