%RegisteredObject to JSON

How to export the %RegisteredObject to JSON in Cache 2016.2?

  • 0
  • 0
  • 470
  • 1
  • 1

Answers

The jsonProvider code may also be invoked from a non-Zen context by calling one of the following APIs:

  • %WriteJSONFromArray
  • %WriteJSONFromObject
  • %WriteJSONStreamFromArray
  • %WriteJSONStreamFromObject
  • %ConvertJSONToObject

proof

Example:

##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(.stream,..%OpenId(1),,,1,"aelqoc")
"<- json = ",stream.Read(),!

16.2 has %ZEN.Auxiliary.altJSONProvider, which has same method signatures but may be preferable (faster).