What JSON on IBM i Can Do For You
October 14, 2015 Alex Woodie
One of the most compelling new features that IBM added to the DB2 for i database in recent memory is support for JavaScript Object Notation (JSON), which has become the de facto standard interchange format for Web data. John Eberhard, a software engineer in IBM’s Rochester lab, recently led IT Jungle through some of the major capabilities that the new JSON data store can provide to all you IBM i shops out there. IBM shipped a technology preview of the new JSON store earlier this year with updates to IBM i 7.1 and 7.2. Unfortunately, the JSON store did not move up to become a fully supported feature in the most recent Technology Refreshes unveiled by IBM last week, so native JSON support in DB2 for i will remain on the cutting edge for now. In any case, it’s clear that JSON is on the minds of IBM’s database developers, and therefore it should be on your radar too. Eberhard, who wrote a developerWorks article called IBM DB2 for i: JSON Store Technology Preview (pdf), says one of the biggest advantages of using JSON in DB2 for i is the ability to share data across multiple systems.
“The primary motivation for using JSON was described in the [2013 developerWorks article] DB2 JSON capabilities, Part 1: Introduction to DB2 JSON,” he tells IT Jungle. “In particular, the use of the JSON store will be most useful in applications where JSON is being used as the transport technology between different systems. The most common case is that of a Web application, where a JavaScript program running in a browser that communicates with a Web server. In this environment, JSON has an additional advantage over other techniques because JSON is easily processed by JavaScript.” Many IBM i developers are beginning to use JavaScript as a front-end scripting language for developing Web and mobile interfaces. While the backend business logic for these apps remain in RPG, Java, PHP, or other language, the front-end is typically written in JavaScript, and quite often the data format it will use is JSON. The developer doesn’t have to use JSON with JavaScript, but there are many advantages to doing it this way–including the fact that you can now store JSON on DB2 for i. Eberhard foresees the best use of the JSON store as a way to easily and efficiently interact with a JavaScript on a browser. “In this model, a Web application would be based mostly in JavaScript running on the browser,” he writes via email. “The JavaScript would generate and manipulate JSON that is exchanged with the server. On the server, the JSON API can be used to not only store and retrieve the document, but to interact with the JSON objects directly.” As Eberhard mentioned, IBM is exposing an API that allows developers to access and manipulate the JSON data stored in the DB2 for i database. That is one way to work with JSON in DB2 for i–the other two being a command line interface for manipulating JSON directly, and a user defined function (UDF) that can be called. (Many third-party software vendors are also supporting JSON in their own ways.) “For the developer, the most important function is the JSON API, which allows Java servlet-based applications to easily produce and process JSON that is exchanged with Web browser applications,” Eberhard says. Since DB2 for i has support for Java procedures and functions, the JSON API can be called by any other IBM i language that speaks SQL, including RPG, PHP, and COBOL. The extensibility of JSON is a clear win for developers looking to build modern Web and mobile applications atop the IBM i platform. Developers who are familiar with other NoSQL databases that use JSON data formats–such as Couchbase and MongoDB (the DB2 JSON store actually implements parts of MongoDB’s open source BSON query engine)–should feel at home working with JSON/BSON documents stored on DB2 for i. But this being IBM–which protects the backward compatibility of its customer’s IT investments stretching back into the decades–you can bet that the JSON DB2 store brings a little something for the operators and administrators tasked with actually running the stuff, too. “For the business, the DB2 JSON Store allows clients to leverage their investments in DR and HA [disaster recovery and high availability] infrastructure to improve their data availability posture,” Eberhard says. “This point resonates with our clients because we’re bridging between two important business requirements: developer productivity and reliability of service.” In many ways, the adventure into JSON technology parallels the adventures IBM i shops have taken with XML, which started becoming a big thing around the turn of the century. “Much like what you saw happen with XML, DB2 for i customers will benefit from having JSON-specific features built into the database,” Eberhard says. “As mentioned earlier, clients can rely upon their considerable investment in DR/HA on IBM i. Even though the JSON collections (documents) are not a column in your favorite table, the data resides in DB2 for i, where you can count on it being there when you need it.” The JSON data store is an important first step in getting JSON data on the IBM i platform. It also brings clear advantages for IBM i shops looking to develop and use modern Web and mobile applications in the manner that has become an industry standard. While traditional relational database technology and SQL-based access methods will continue to power many of the internal processes that IBM i servers run on a daily basis, the query and storage methods used to serve data to Web and mobile user interfaces is clearly shifting toward document-oriented designs, with JSON leading the way. RELATED STORIES Top Five New Technologies On IBM i Using JSON and RPG To Create Interactive Web 2.0 Applications
|