Home Applications GlobalToJSON-ePython-pure

GlobalToJSON-ePython-pure

This application is not supported by InterSystems Corporation. Please be notified that you use it at your own risk.
4.5
1 reviews
0
Awards
235
Views
11
IPM installs
3
2
Details
Releases
Reviews
Issues
Pull requests
Articles
JSON Object from Global using embedded Python only

What's new in this version

move to archive

GlobalToJSON-embeddedPython-pure

Export a Global into a JSON file and re-create it by reloading from this file. embeddedPython
refers to the new available technologies. It should be understood as a learning exercise of how to
handle the language interfaces. The mayor difference to its predecessor package is:
only embedded Python is used as a demand of the related contest to demonstrate it is doable.
Only Global nodes containing data are presented in the generated JSON file.

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-ePython-pure.git

Run the IRIS container with your project:

docker-compose up -d --build

How to Test it

ObjectScript Wrapper

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 file from Global
USER>set sc=##class(dc.GblToJSON.ePure).do("^dc.MultiD","gbl.json")
USER>

This is the file content

gbl.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.ePure).load("gbl.json")
done

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>

Python command line

shell
cd /irisdev/app/src/Python
/usr/irissys/bin/irispython ePure.py dump --file /tmp/global.json --glob ^dc.MultiD

to see the generated file:

more /tmp/global.json

to load it

/usr/irissys/bin/irispython ePure.py load --file /tmp/global.json

q.a.d.

Article in DC

Video

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