Home Applications GlobalToJSON-Academic

GlobalToJSON-Academic

This application is not supported by InterSystems Corporation. Please be notified that you use it at your own risk.
5
1 reviews
0
Awards
185
Views
10
IPM installs
4
2
Details
Releases
Reviews
Issues
Pull requests
Articles
create JSON Object from Global and with Importer in all details

What's new in this version

polish docker

GlobalToJSON-Academic

This package offers a utility to load a Global into JSON object and to create a
Global from this type of JSON object. Academic refers to the structure created.
Each logical node of the Global is presented separately with all its descendants
even if they don’t contain any stored data.

Prerequisites

Make sure you have git and Docker desktop installed.

Installation

Clone/git pull the repo into any local directory

git clone https://github.com/rcemper/GlobalToJSON-Academic.git

Run the IRIS container with your project:

docker-compose up -d --build

How to Test it

This is the pre-loaded Global ^dc.MultiD for testing.

Open IRIS terminal

$ docker-compose exec iris iris session iris
USER>

USER>; generate JSON object from Global

USER>set json=##class(dc.GblToJSON.A).do("^dc.MultiD")

USER>zw json
json={"node":"^dc.MultiD","val":"5","sub":[{"node":"1","val":"$lb("Braam,Ted Q.
",51353)","sub":[{"node":"mJSON","val":"{}"}]},{"node":"2","val":"$lb("Klingma
n,Uma C.",62459)","sub":[{"node":"2","sub":[{"node":"Multi","sub":[{"node":"a",
"val":"1"},{"node":"rob","sub":[{"node":"1","val":"rcc"},{"node":"2","val":"2222
"}]}]}]},{"node":"Multi","sub":[{"node":"a","val":"1"},{"node":"rob","sub":[{"no
de":"1","val":"rcc"},{"node":"2","val":"2222"}]}]},{"node":"mJSON","val":"{"A"
:"ahahah","Rob":"VIP","Rob2":1111,"Rob3":true}"}]},{"node":"3","val":"
$lb("Goldman,Kenny H.",45831)","sub":[{"node":"mJSON","val":"{}"}]},{"node":"4
","val":"$lb("","")","sub":[{"node":"mJSON","val":"{"rcc":122}"}]},{"node"
:"5","val":"$lb(&quot;&quot;,&quot;&quot;)","sub":[{"node":"mJSON","val":"{}"}]}]} ; <DYNAMIC OBJECT>

USER>; this is rather hard to read and follow

USER>write $$Do^ZPretty(json)

Now we want to verify the load function.
First we make a copy of our source and then delete the source
After the load operation the source Global is completely restored

USER>merge ^keep=^dc.MultiD  

USER>kill ^dc.MultiD

USER>set sc=##class(dc.GblToJSON.A).load(json)

USER>zw sc
sc=1

USER>zw ^dc.MultiD
^dc.MultiD=5
^dc.MultiD(1)=$lb("Braam,Ted Q.",51353)
^dc.MultiD(1,"mJSON")="{}"
^dc.MultiD(2)=$lb("Klingman,Uma C.",62459)
^dc.MultiD(2,2,"Multi","a")=1
^dc.MultiD(2,2,"Multi","rob",1)="rcc"
^dc.MultiD(2,2,"Multi","rob",2)=2222
^dc.MultiD(2,"Multi","a")=1
^dc.MultiD(2,"Multi","rob",1)="rcc"
^dc.MultiD(2,"Multi","rob",2)=2222
^dc.MultiD(2,"mJSON")="{""A"":""ahahah"",""Rob"":""VIP"",""Rob2"":1111,""Rob3"":true}"
^dc.MultiD(3)=$lb("Goldman,Kenny H.",45831)
^dc.MultiD(3,"mJSON")="{}"
^dc.MultiD(4)=$lb("","")
^dc.MultiD(4,"mJSON")="{""rcc"":122}"
^dc.MultiD(5)=$lb("","")
^dc.MultiD(5,"mJSON")="{}"

USER>

q.a.d.

Article in DC

Video

Made with
Install
zpm install gbl-to-json-a download archive
Version
0.0.416 Sep, 2023
Ideas portal
https://ideas.intersystems.com/ideas/DP-I-156
ObjectScript quality test
Category
Technology Example
Works with
InterSystems IRIS
First published
25 Jan, 2022
Last checked by moderator
01 Nov, 2023Works