© 2024 InterSystems Corporation, Cambridge, MA. All rights reserved.Privacy & TermsGuaranteeSection 508Contest Terms
move to archive
It’s also an example for a customized command extension (ZZJSN) in Caché & IRIS
This is the Caché version for fast JSON formatting but it also works in IRIS.
Requires package ZPretty
To allow parallel existence in IRIS this is named ZZJSN
see:
USER>ZWRITE jsn
jsn="{"Name":"Li,Robert K.","SSN":"672-92-9664","DOB":"1975-01-12","Home":{"Street":"986 Washington Blvd","City":"Boston","State":"PA","Zip":"95802"},"Office":{"Street":"6012 First Place","City":"Reston","State":"MT","Zip":"77739"},"Spouse":{"Name":"Avery,Zelda H.","SSN":"323-13-7437","DOB":"1943-03-27","Home":{"Street":"196 Main Drive","City":"Youngstown","State":"WY","Zip":"53229"},"Office":{"Street":"4056 Franklin Court","City":"Bensonhurst","State":"IA","Zip":"27688"},"FavoriteColors":["Black"],"Age":77},"Age":45,"Title":"Associate Marketing Manager","Salary":10421}"
This doesn’t look so easy to follow.
So this is a shorthand to save time and reduce mistyping.
The attached ZZJSN.inc is to be included into your %ZLANGC00.mac
USER>ZZJSN jsn ; does the Output to Terminal / Device
{
"Name":"Li,Robert K.",
"SSN":"672-92-9664",
"DOB":"1975-01-12",
"Home":{
"Street":"986 Washington Blvd",
"City":"Boston",
"State":"PA",
"Zip":"95802"
},
"Office":{
"Street":"6012 First Place",
"City":"Reston",
"State":"MT",
"Zip":"77739"
},
"Spouse":{
"Name":"Avery,Zelda H.",
"SSN":"323-13-7437",
"DOB":"1943-03-27",
"Home":{
"Street":"196 Main Drive",
"City":"Youngstown",
"State":"WY",
"Zip":"53229"
},
"Office":{
"Street":"4056 Franklin Court",
"City":"Bensonhurst",
"State":"IA",
"Zip":"27688"
},
"FavoriteColors":[
"Black"
],
"Age":77
},
"Age":45,
"Title":"Associate Marketing Manager",
"Salary":10421
}
output to stream
set st=##class(%Stream.GlobalCharacter).%New()
ZZJSN jsn:st ; write result to Stream
output to string
ZZJSN jsn:"BOBBY" ; writes it to local variable BOBBY