Seems like the JSONTYPE as Property-Parameter is only available in IRIS.
Therefore I've now implemented the solution suggested by @Timothy Leavitt with own datatype-classes using the JSONTYPE class-paramter. So far it seems to work.
Hope we could upgrade to IRIS anytime soon. But unfortunately we are not quite there yet.
Class test.TestJSONExport Extends (%RegisteredObject, %ZJSON.Adaptor)
{
Property int As %Integer;
Property bool As %Boolean;
Property str As %String(MAXLEN = "");
ClassMethod test()
{
set obj = ..%New()
set obj.bool=1
set obj.int=12
set obj.str="TEST"
set sc = obj.%JSONExport()
}
}
With this I get the following terminal-output:
do ##class(test.TestJSONExport).test()
{"int":"12","bool":"true","str":"TEST"}
Is it because I'm using the backported %ZJSON from Robert in Caché?
Just for additional clarification because I ran across this problem: the URL Map in the forwarded class (Api.v1 in your example) must not contain the Prefix of the URL (/v1 in your example). Its just the remainder of the REST URL that will be processed by the URL Map of the subclass.
go to post
Hi Robert,
I've already testet your fix with my code.
It works just fine in Caché, even without the customized datatype classes - thanks!
Regards, Thomas
go to post
Seems like the JSONTYPE as Property-Parameter is only available in IRIS.
Therefore I've now implemented the solution suggested by @Timothy Leavitt with own datatype-classes using the JSONTYPE class-paramter. So far it seems to work.
Hope we could upgrade to IRIS anytime soon. But unfortunately we are not quite there yet.
Thanks!
Thomas
go to post
I've adapted your simple example:
With this I get the following terminal-output:
Is it because I'm using the backported %ZJSON from Robert in Caché?
https://community.intersystems.com/post/backport-json-cach%C3%A9
Thanks!
Thomas
go to post
The date should be thursday not tuesday, right?
go to post
XMLSEQUENCE is the parameter I was searching for - thank you Tomas!
But your are right of course: you have to be careful when setting the XMLSEQUENCE to 0.
go to post
Thank you Eduard - works great!
Just for additional clarification because I ran across this problem: the URL Map in the forwarded class (Api.v1 in your example) must not contain the Prefix of the URL (/v1 in your example). Its just the remainder of the REST URL that will be processed by the URL Map of the subclass.
Thomas
go to post
Thanks Dimitry! That was exactly what I was searching for!
Thomas