Home Applications fast-JSON-formatting-IRIS

fast-JSON-formatting-IRIS

InterSystems does not provide technical support for this project. Please contact its developer for the technical assistance.
4.5
1 reviews
0
Awards
361
Views
26
IPM installs
6
4
Details
Releases (11)
Reviews (1)
Issues
Articles (1)
fast JSON formatting in IRIS

What's new in this version

Automatic version update

Fast JSON formatting (IRIS)

It’s also an example for a customized command extension (ZZJSON) in IRIS

IRIS has a nice %JSON.Formatter class.
But for debugging it is not really handy.
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""]}"   

so you proceed for the most simple case

set formatter=##class(%JSON.Formatter).%New()   
do formatter.Format(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"  
  ]  
}  

Not a big thing.
You do it once, you do it twice, and after the 5th time your fingers get tired.

So this is a shorthand to save time and reduce mistyping.

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:"BOBBY"  ; writes it to local variable BOBBY

Article in DC

Made with
Install
zpm install fast-json-format download archive
Version
1.0.725 Mar, 2024
ObjectScript quality test
Category
Technology Example
Works with
InterSystems IRIS
First published
21 Jul, 2020
Last edited
16 Sep, 2023
Last checked by moderator
26 Nov, 2024Doesn't work