Learn more >
by Bobbie Cochrane, Kathy McKnight | Updated June 21, 2013 - Published June 20, 2013
There is a new style of applications evolving, driven by many forces converging simultaneously. The rapid rise and ubiquity of mobile and social applications are stimulating increased levels of interaction between humans through electronic means. Cloud computing makes compute resources readily available, and the advent of big data technology makes it possible to derive insights over massive amounts of data collected from the internet, sensors and mobile devices. The availability of user interaction data, the ease of access to compute resources and the advances in big data technology enable businesses to predict a customer’s behaviors and needs far better than they ever have before. All these forces together are providing new opportunities for businesses to engage with their customers in meaningful ways. In fact, consumers who use social media and mobile applications have come to expect applications that are engaging and easily accessible through many form factors, especially their mobile devices.
These new applications are designed and delivered to mobile devices first, driving an increase in social and mobile interactions. Enterprises are now looking to quickly provide gateways to their enterprise systems in order for them to participate in these new mobile and social interactions. They are moving from a simple transaction based world to an interaction based world. Businesses need to be able to expand and complement enterprise systems of record with systems of engagement, and do this while maintaining the enterprise capabilities intact – robustness, privacy, security and high availability. IBM is embracing this use of JSON by implementing a popular JSON API, MongoDB API, in our DB2 platform.
The following is a simple example of a JSON document:
"title": "The Ultimate Database Study Guide",
"abstract": "What you always wanted to know about databases and were afraid to ask",
"category": ["Non‑Fiction", "Technology"],
"ratings": 10, 5, 32, 78, 112}
JSON facilitates the portability of structured data by defining a minimal set of concepts. The primary concept in JSON is the object, which is an unordered collection of name/value pairs, where the value can be any JSON value. There are 4 atomic concepts in JSON common to most programming languages:
Arrays introduce ordered sequences of values, which again, can be a JSON value of one of the 4 previously mentioned JSON types. JSON objects can be nested, but are not commonly deeply nested.
One of the accolades often quoted for JSON is that it is text-based and position-independent, but XML also shares these features. Why then is JSON gaining popularity over XML for APIs? In 2011, Programmable Web reported that 1 in 5 new APIs were choosing JSON over XML; this grew to 1 in 4 by December 2012 (see the Resources section for a link to a blog topic on the choice of JSON over XML). Furthermore, many of the established players, such as Box.net and YouTube are switching from XML to JSON. A few factors contribute to this.
First, JSON is simpler and is all about working with objects. It does not attempt to be a document markup language in addition to a data exchange language. This dual purpose of markup and exchange language makes it more difficult for humans to work with XML. Because of its simplicity, JSON is more compact, requiring fewer bits to store, flow across the network, and process on mobile and embedded devices.
It is then not surprising that JSON is also becoming the predominant technology leveraged by NoSQL document stores, such as MongoDB and CouchDB.
By providing JSON support in the database tier, we are able to provide the agility gained through schema flexibility to developers of new era applications. Additionally, JSON gives developers greater synergy with their programming language of choice, and allows direct, native storage for the data that is flowing from the mobile device, through the application tier to the disk. This reduces overhead for data transformation and shedding.
DB2 JSON is a driver-based solution that embraces the flexibility of the JSON data representation within the context of an RDBMS that provides well-known enterprise features and quality of service. With this offering, users can program their modern application data needs in DB2 using a JSON programming paradigm that is modeled after the MongoDB data model and query language which has arisen as one of the most popular and prolific JSON data stores in the industry. The JSON data is stored in a binary-encoded format called BSON (Binary JSON). BSON is designed to be lightweight, easily traversed and very efficiently encoded and decoded. In addition, MongoDB provides native support for additional data types commonly used by application developers such as date. These extensions have also been added to DB2 JSON support.
Using DB2 JSON, users can interact with JSON data in many ways. First, they can administer and interactively query JSON data using a command line shell. Second, they can programmatically store and query data from Java programs using an IBM provided Java driver for JSON that allows users to connect to their JSON data through the same JDBC driver used for SQL access. Finally, they can use any driver that implements the MongoDB protocol. This allows them to access their DB2 JSON store from a variety of modern languages, including node.js, PHP, Python,and Ruby, as well as more traditional languages such as C, C++, and Perl.
Details for these capabilities are further explained in a series of companion articles as outlined below:
The following diagram illustrates the setup and control flow of the JSON API support.
The DB2 JSON command line is a command shell for performing administrative commands for JSON document collections and for running queries and update operations against the JSON collections. It is very similar to the DB2 CLP interface.
For more information on the command line, refer to DB2 JSON Capabilities, Part 2: Using the command-line processor.
The DB2 JSON Java API provides a set of methods for storing, retrieving and manipulating JSON documents. These methods can be called by native Java applications directly through the API to work with the documents in the database. Since DB2 is the data store, this component translates the operations requested in the method invocations into SQL statements.
For more information on the Java API, refer to “DB2 JSON Capabilities, Part 3: Using the JAVA API“.
The DB2 JSON wire listener is a server application that intercepts the Mongo Wire Protocol. It acts as a mid-tier gateway server between MongoDB applications and DB2. It leverages the DB2 for JSON API in order to interface with DB2 as the data store. A user can execute a MongoDB application written in the desired application programming language (JAVA, NodeJS, PHP, Ruby, etc), or can use the MongoDB CLI to communicate with DB2.
For more information on the wire listener, refer to “DB2 JSON Capabilities, Part 4: Using the Wire Listener“.
This article has provided an overview of the DB2 JSON technology which enables developers to write applications using a popular JSON-oriented query language created by MongoDB to interact with data stored in IBM DB2 for Linux, UNIX, and Windows or DB2 for z/OS.
With DB2 JSON support, developers get the best of both worlds: agility with a trusted foundation of DB2. Users do not need to rip and replace their DB2 implementations to be able to leverage agile paradigms in the new era of applications. DB2 10.5 is the first system to provide relational, columnar (DB2 BLU), XML, and JSON data in the same storage engine. You now have the ability to rapidly prototype new applications to complement enterprise systems of record with systems of engagement by leveraging the NoSQL JSON paradigm and flexible schemas, provide fast storage for analytics with DB2 BLU columnar store, alongside their well-known relational applications. At the same time, you preserve the traditional DBMS capabilities, leveraging existing skills and tools.
To link to the download image for the technology, see the Related topics section.
September 13, 2019
August 15, 2019
API ManagementArtificial intelligence+
See how a fictional health care company uses cloud technology to access data stored on z/OS systems.
Back to top