Overview
This article provides information about a procedure in G2 that can be used to parse JSON data.
Information
G2 2020.4 and up provides the g2-unmarshal-json
procedure, which parses JSON text into G2 sequences and structures. This is the only current process to parse JSON data inside of G2. For marshalling, regular G2 interpolating is recommended.
The g2-unmarshal-json
procedure can be found in the g2web
module. To be able to use it, this module needs to be merged into the current KB. The G2web module can be found in the installation directory under "<installation-dir>\g2\kbs\utils\g2web.kb
".
This procedure follows the same restrictions as the XML parse procedures. Because of this, it is not recommended to parse large JSON files. While reading or transferring very large strings, G2 performs no other processing.
The attached KB illustrates how the procedure can be used to parse a small JSON. To see it in action, load the KB and start G2. Once the KB is started, press the Start Unmarshal button. The procedure will post to the message board the JSON parsed into a structure object.
Note: G2 versions 2020 need a license which is different from the previous versions. If you need to upgrade, contact support and request the appropriate license for your servers.
Comments
1 comment
A few comments:
g2-unmarshal-json
, but without this option I can't.Please sign in to leave a comment.