RPG Next Gen
Wiki RSS Feed Weblog
Business picture

JSON Utilities

What is JSON? JSON is a way of passing data between application independent of the underlying programming language or platform.

But you probably should have a look at the JSON site and then come back.

JSON Service program

The provided service program allows the creation, parsing, checking and serializing/deserializing to/from stream files of JSON strings through a number of procedures. See the examples section for an example on how to create a JSON string.

Most things like arrays, objects and null values are supported by this service program.

The service program consists of multiple modules:

  • JSON — Main module and Generator
  • JSON_ARR — Array support
  • JSON_CHK — Validator/Checker
  • JSON_CUTIL — Checker utilities
  • JSON_PAR — Parser
  • JSON_UTIL — Utilities

JSON and Java

Java has many ways of dealing with JSON strings and most are accomplished very easy.

So, if Java can read JSON strings very easy and RPG can write JSON strings very easy then this makes a good combination for data exchange between RPG and Java.

Missing numeric (zoned / packed) data type

For those who have to pass some numeric values which don't fit into the primitive data types int, long and double there is also the JTOpen project with a lot of Java classes which can help in data exchange between Java and RPG. The biggest handicap is that Java does not have data structures like RPG (which makes it easy to pass multiple values in one parameter) and the ProgrammCall class of the toolbox only accepts 7 parameters (due to some API limitations).

Record Format Markup Language

But there jumps RFML into the arena. RFML is a markup language to define record formats. These record formats can be filled with the content (bytes) of a ProgramCall parameter and then be used in the same way as an RPG data structure.

RFML is quite universal as it can be used with

  • ProgramCall parameters
  • Userspaces
  • Data Queues
  • Data Areas
  • Database Files

Limitations

Objects and arrays are supported with "unlimited" cascading depth. The only limit is the memory available for the job.

License

This library is licensed under the GNU Lesser General Public License.

Requirements

The service program ARRAYLIST is needed for this service program.

Documentation

Documentation is provided by the open documentation library at the ILEDocs website.

Download

The source code of the service program can be found in the download section.

The source code to some examples can be found in the examples section.

Source Code Repository

The JSON source code is now checked into a SVN repository on Sourceforge.net.

https://svn.code.sf.net/u/fist/src/json