noxDB - Not Only XML - is a software library which makes it easy to parse and generate JSON and XML. Generating JSON or XML directly from an SQL is even easier with noxDB. noxDB has become my favorite tool when working with JSON or XML when I want to process it with a DOM like approach … which is most of the time.
But to top it all off we can make it even easier. Till now it was a bit of a pain to install noxDB (depending on your environment, f. e. installed tools). This has been alleviated as we now have a nice RPM package which can be used with iPKG. To install noxDB with iPKG we just need the iPKG client on our machine (available here) and execute the install command.
ipkg install noxdb2
This will install the noxDB service program (NOXDB2) in the library IPKG and also adds it to the
binding directory IPKG in the installation library. The installation library can be specified on
the install command with the parameter
If you want to use the service program you will need the RPG prototypes. These are also packaged and can be installed in the same manner.
ipkg install 'noxdb2-devel'
The prototypes are saved in a stream file. By default this stream file will be placed in the IFS
in the folder
/usr/local/include. But this can also be changed on the install command with the
iPKG is not a global package manager. It works more like NPM where packages are managed on a per project base (per library in our case). To make a package installation only for a single user you just need to specify a separate library on the install command. To have noxDB installed in my own library and home directory I would call the following commands:
ipkg install noxdb2 ipkglib(MIHAEL)
Note: The noxdb2 package provides the
utf8 branch of the noxDB project which is not yet on par
with the main branch when it comes to functionality but covers all the basics already.
Now that we have installed noxDB how to use it in RPG?
- noxDB installed in library MIHAEL (service program NOXDB2)
- NOXDB2 registered in the binding directory MIHAEL/IPKG
- library MIHAEL is part of the library list
- noxDB2 prototypes installed in folder
- prototypes available at
We are now set for creating our first RPG program with the new noxDB installation. It will be a FREE RPG program (though we can also use it in a non FREE RPG program but it has to be an ILE program). So our program starts with
For this little example we compile it in one go with the command
CRTBNDRPG so we can add some
compile options in the code (for production I would go with the two step approach of first
creating a module with
CRTRPGMOD and then creating the program with
ctl-opt dftactgrp(*no) actgrp(*caller) bnddir('IPKG');
Next we need to include the noxDB prototypes.
I like to directly jump into a procedure at program start without forfeiting the default error handler.
And here is our main procedure where we parse a JSON string, modify the noxDB object graph and
output it with the
As noxDB is now available via iPKG providing ILEastic as a RPM package for usage with iPKG is on my list.