%ZEN.Auxiliary.jsonProvider object to json serialization

Hi community,

I am having a hard time figuring out how to properly use %ZEN.Auxiliary.jsonProvider to serialize a %RegisteredObject to JSON. Would be anyone so kind to share some simple usage example?

Thanks

Jiri

  • 0
  • 0
  • 275
  • 1
  • 1

Answers

Example!

Class:

------------------------------------------

Class Jiri.RegisteredObject extends %RegisteredObject {

Property p1;

Property p2;

}

------------------------------------------

 

Terminal:

------------------------------------------

SAMPLES>s j=##class(Jiri.RegisteredObject).%New()

SAMPLES>s j.p1="test"

SAMPLES>s j.p2="json"

SAMPLES>w ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(.stream,j)

1

SAMPLES>w stream.Read()

{

"_class":"Jiri.RegisteredObject",

"p1":"test",

"p2":"json"

}

------------------------------------------

 

Oh, I was trying to coerce a wrong method apparently ... thanks!