By default %ToJSON method prints empty properties.
If you pass pFormat without "e" flags (that is passed by default), then empty properties are skipped:
USER>set p = ##class(%ZEN.proxyObject).%New()
USER>set p.a = 1
USER>set p.b = 2
USER>do p.%ToJSON()
{
"a":1,
"b":2
}
USER>set p.b = ""
USER>do p.%ToJSON()
{
"a":1,
"b":""
}
USER>do p.%ToJSON(,"alotw")
{
"a":1
}
I encourage you to use Caché 2016.1 with native JSON support. Don't start with %ZEN.proxyObject. See great article by Stefan Wittman about JSON support in 2016.1: https://community.intersystems.com/post/introducing-new-json-capabilities-cach%C3%A9-20161
- Log in to post comments
