We’re constantly working to roll out new products and features and we’ve got big news for RPG-XML Suite 3.3 – it includes JSON support!

This article was originally posted on our RPG-XML Suite product website, and has since been updated.

With our new APIs, you can compose, transmit, and parse JSON data using RPG on your IBM i.

What is JSON?

The acronym JSON (pronounced JAY-son) stands for JavaScript Object Notation. Don’t worry – it doesn’t actually require experience with JavaScript (a common scripting language used in internet applications) to read or use JSON data. JSON is a simple data interchange format that is easy to read and approachable for even novice developers. It is widely supported by many common programming languages – for example, PHP, Java, Ruby, and, of course, JavaScript – on multiple platforms.

JSON has a very simple syntax, or code structure, with less markup and overhead than one would see in an XML document. JSON data is stored as key/value pairs1, where each data value is paired with a label. Here is an example of a key/value pair:

"Company_Name": "Krengel Technology"

The same data might be represented in XML like this:

<companyName>Krengel Technology</companyName>

The XML sample looks a lot more like code, doesn’t it? Apart from some extra quotation marks, the JSON sample could be an item in a table or list. That’s why they say JSON is very human-readable! With its more simple syntax, it’s easier to get information from JSON code at a glance without having to read through complex tags and nested elements.

How Does JSON Compare to XML?
JSON and XML fulfill many of the same basic functions – they’re both designed to structure data both for transmission as well as for configuration, and both have support in many programming languages. However, each has their respective strengths and weaknesses. Here are a selection that are particularly applicable to offering and consuming web services:

The main advantage of XML over JSON is the use of schemas for strict document definitions. While more work is being done to create usable JSON schema validators, there is not yet a widely supported approach, and is it not common to see these in practice. The only validation done by most JSON parsers is to confirm that the presented data is in a valid JSON format. If you require a strictly formatted structure, with ordered or required elements, XML may still be the best way to go.

Where is JSON Used?
JSON has become popular with web services because of its small data footprint and language-independent format. Companies like Google, Twitter, and Microsoft return JSON data from their web services. Amazon has introduced JSON-based web services for many of their cloud computing solutions, including their Glacier cold data storage and their Machine Learning data processing and pattern recognition service.

You can even use RPG-XML Suite to create your own web service that consumes and/or returns JSON data, in much the same way as you would for XML. This flexible format offers limitless possibilities, and we’re eager to help you explore all that JSON has to offer!

Contact our development team at isupport@krengeltech.com to explore how RPG-XML Suite can meet your specific JSON communication requirements on IBM i.

1 – There is much more to JSON syntax than just simple key/value pairs, but that goes beyond the scope of this article. For a thorough run-down of JSON data types and structures, visit the official JSON website, and see an excellent code example on Wikipedia. (back)

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *