Question
Jiri Svoboda · Feb 3, 2017

%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

00
2 0 2 484
Log in or sign up to continue

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!