As technologies and software develop, new data standards are adopted, with JSON being the newest one. After Kato Integration’s release of RPG API Express version 3.4.0, we have added numerous features and bugfixes, enhancing RPG API Express’s parsing and composition APIs. Because of these changes, we’re updating some of our most perennial content.
We’re constantly working to roll out new products and features and we’ve got big news for RPG API Express version 3.3 – it includes enhanced JSON support! With our updated APIs, you can compose, transmit, and parse JSON data using RPG on your IBM i.
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 pairs, where each data value is paired with a label. Here is an example of a key/value pair:
"Company_Name": "Kato Integrations"
The same data might be represented in XML like this:
Note: 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.
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.
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.
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 API Express 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 support team here to explore how RPG API Express can meet your specific JSON communication requirements on IBM i.