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"))
}
}
The short answer is: NO.
The long answer is:
if you try to make a trick, like the below code: it won't work.
now the surprise:
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.
I know, hence my "... won't work" comment.