Skip to content

Commit a385714

Browse files
committed
Correct handling of JSON as a setting
1 parent cc1fee7 commit a385714

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

MDX2JSON/AbstractREST.cls.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,5 +413,48 @@ This is the Schema which defines the form of the dispatch map</Description>
413413
</xs:schema>
414414
]]></Data>
415415
</XData>
416+
417+
<Method name="POtoStr">
418+
<ClassMethod>1</ClassMethod>
419+
<FormalSpec>config</FormalSpec>
420+
<ProcedureBlock>0</ProcedureBlock>
421+
<ReturnType>%String</ReturnType>
422+
<Implementation><![CDATA[
423+
424+
set str=""
425+
426+
//Redirect IO to the current routine - makes use of the labels defined below
427+
use $io::("^"_$ZNAME)
428+
429+
//Enable redirection
430+
do ##class(%Device).ReDirectIO(1)
431+
432+
do config.%ToJSON()
433+
434+
//Disable redirection
435+
do ##class(%Device).ReDirectIO(0)
436+
437+
quit str
438+
439+
//Labels that allow for IO redirection
440+
//Read Character - we don't care about reading
441+
rchr(c) quit
442+
//Read a string - we don't care about reading
443+
rstr(sz,to) quit
444+
//Write a character - call the output label
445+
wchr(s) do output($char(s)) quit
446+
//Write a form feed - call the output label
447+
wff() do output($char(12)) quit
448+
//Write a newline - call the output label
449+
wnl() do output($char(13,10)) quit
450+
//Write a string - call the output label
451+
wstr(s) do output(s) quit
452+
//Write a tab - call the output label
453+
wtab(s) do output($char(9)) quit
454+
//Output label - this is where you would handle what you actually want to do.
455+
// in our case, we want to write to myStream
456+
output(s) set str=str_s quit
457+
]]></Implementation>
458+
</Method>
416459
</Class>
417460
</Export>

MDX2JSON/REST.cls.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Wrapper for ##class(MDX2JSON.Users).GetConfig()</Description>
266266
<FormalSpec>Application</FormalSpec>
267267
<ReturnType>%Status</ReturnType>
268268
<Implementation><![CDATA[
269-
w "{""Config"":""" _ ##class(MDX2JSON.Users).GetConfig(Application) _ """}"
269+
w "{""Config"":" _ ##class(MDX2JSON.Users).GetConfig(Application) _ "}"
270270
return $$$OK
271271
]]></Implementation>
272272
</Method>
@@ -278,8 +278,8 @@ Wrapper for ##class(MDX2JSON.Users).SetConfig()</Description>
278278
<ReturnType>%Status</ReturnType>
279279
<Implementation><![CDATA[
280280
set config = $$$R("Config")
281-
if (($IsObject(config)) && (config.%IsA("%ZEN.proxyObject"))) {
282-
set config = config.%ToJSON()
281+
if (($IsObject(config)) && (config.%IsA("%ZEN.proxyObject"))) {
282+
set config = ..POtoStr(config)
283283
}
284284
return ##class(MDX2JSON.Users).SetConfig($$$R("Application"),config)
285285
]]></Implementation>

0 commit comments

Comments
 (0)