Sandbox Tutorial for JSON

This section provides a tutorial that will help you build a Java application using the MapR Database JSON Java API library.

This tutorial is an implementation of the Open JSON Application Interface (OJAI) API library. Basic information about using the MapR Database Shell (JSON Tables) utility for JSON tables is also included in this document.

About OJAI

The MapR Database JSON Java API library leverages MapR Database support for OJAI in many areas, including:

  • Tables
  • Sub-documents
  • Efficient access to data
  • Large document support
  • Security

Key features of the API library include:

  • APIs for manipulating JSON documents
  • Extensions to the Hadoop ecosystem:
    • Efficient parsing of large files
    • MapReduce integration

JSON Support

MapR Database, in addition to its support of the key-value model (column family), now offers a Document Model. This means that applications can use a JSON document to represent data. JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
A document looks like this:
{
    "_id" : "001",
    "first_name" : "John",
    "last_name" : "Doe",
    "age" : 45,
    "email" : "jd@mydoc.com",
    "interests" : ["sports", "movies"],
    "address" : {
        "street" : "1015 Main Street",
        "city" : "San Jose",
        "state" : "CA",
        "zip" : "95106"
    }
}

MapR Database stores the documents in tables. An interesting aspect of MapR Database JSON is that inside a table, documents can have a different structure.

Documents inside MapR Database must have a unique identifier stored in the _id field.

MapR Database does not store the documents as a whole in a single location. Instead, MapR Database creates fields for each attribute and nested documents/attributes. This allows MapR Database to access the information very efficiently. When you read, for example using projection, or when you edit a document, only the necessary fields will be modified. MapR Database can store very large documents, for example, multi-GB documents, if the application requires it.

Prerequisites