Short-JSON-Formatting-for-CACHEShort-JSON-Formatting-for-CACHE
Watch
0
Star
0
Category
Developer Environment
Works with
Tags
Author
Otto.K
Version
1.0.0
Last updated
2019-11-25
Repository
Documentation
License
Download
Discuss
Details
Version history
Issues
Discuss

What's new in this version

Initial Release

Back-port of %JSON.Formatter from IRIS to Caché + Command ZZJSON for CACHÉ

Short-JSON-Formatting-for-CACHÉ

Customized Command ZZJSON for CACHÉ

IRIS brought us an excellent %JSON.Formatter class.
I did a backport to Caché to have it also availaible there
It consists of %ZZ.JSON.Formatter.cls and %ZZPVA.inc
But for debugging it is stil not handy enough. So ZZJSON.inc was also included.

as for IRIS see:

ZWRITE js1  
js1="{""Name"":""Cunningham,John C."",""SSN"":""294-11-9150"",""DOB"":""1933-01-08"",""Home"":{""Street"":""4249 Ash Street"",""City"":""Tampa"",""State"":""MD"",""Zip"":""30176""},""FavoriteColors"":\[""White"",""Red"",""Green""]}"   

or

WRITE js1  
{"Name":"Cunningham,John C.","SSN":"294-11-9150","DOB":"1933-01-08","Home":{"Street":"4249 Ash Street","City":"Tampa","State":"MD","Zip":"30176"},"FavoriteColors":\["White","Red","Green"]}

so you proceed for the most simple case

ZZJSON js1    ;now on Caché
{   
  "Name":"Cunningham,John C.",  
  "SSN":"294-11-9150",  
  "DOB":"1933-01-08",  
  "Home":{  
     "Street":"4249 Ash Street",  
     "City":"Tampa",  
     "State":"MD",  
     "Zip":"30176"  
  },  
  "FavoriteColors":\[  
    "White",  
    "Red",  
    "Green"  
  ]  
}  

The attached ZZJSON.inc is to be included into your %ZLANGC00.mac

ZZJSON js1         ; does the Output to Terminal / Device  
set st=##class(%Stream.GlobalCharacter).%New()
ZZJSON js1:st      ; write result to Stream
ZZJSON js1:"OTTO"  ; writes it to local variable OTTO