Skip to content

Instantly share code, notes, and snippets.

@grongierisc
Last active July 5, 2021 16:57
Show Gist options
  • Save grongierisc/47181a6282ec788fa1664f0b333c456e to your computer and use it in GitHub Desktop.
Save grongierisc/47181a6282ec788fa1664f0b333c456e to your computer and use it in GitHub Desktop.
Class User.Util
{
ClassMethod EmptyToNull(dyna As %DynamicObject) As %DynamicObject
{
set iter = dyna.%GetIterator()
while iter.%GetNext(.key , .value ) {
if value = "" {
do dyna.%Set(key,"","null")
}
if dyna.%GetTypeOf(key) = "object" {
do dyna.%Set(key,..EmptyToNull(value))
}
if dyna.%GetTypeOf(key) = "array" {
set iterArray = value.%GetIterator()
while iterArray.%GetNext(.keyArray , .value ) {
do:(value'="") ..EmptyToNull(value)
}
}
}
Return dyna
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment