Question
· Sep 8, 2019

Set NULL in dynamic object

Is there a way to set null in dynamic object without using %Set methods?

I have this method and I need to set NULL as, well, null and not string.

ClassMethod node(name) [ CodeMode = expression ]
{
{
    "name":(name),
    "content":($case(##class(%Dictionary.ClassDefinition).%ExistsId(name), $$$YES:"mycontent", $$$NO:"NULL"))
}
}
Discussion (3)1
Log in or sign up to continue

Yes, because everything you put between parenthesis is evaluated/casted back to COS language, and since there's no NULL in COS, you get an empty string as value and string as its type.

The only way is to have a custom serializer that reads the "null", "false" and "true" and interpret them as it seems fit. This  is how I did by the way.