Chapter 6. JSON Processing

JSON Processing is defined as the Java API for JSON Processing in JSR 353, and the complete specification can be downloaded.

JSON (JavaScript Object Notation) is a lightweight data-interchange format. The format is easy for humans and machines to read and write. JSON was based on a subset of JavaScript and is commonly used with it, but it is a language-independent data format. A JSON structure can be built as either of the following:

  • A collection of name/value pairs, generally realized as dictionary, hash table, or associative array

  • An ordered list of values, generally realized as an array, list, or sequence

The following example shows the JSON representation of an object that describes a movie:

  "name": "The Matrix",
  "actors": [
    "Keanu Reeves",
    "Laurence Fishburne",
    "Carrie-Ann Moss"
  "year": 1999

The object has three name/value pairs. The first name is name with a string value for the movie name, the second name is actors with an array value for the actors in the movie, and the third name is year with a number value for the year the movie was released.

JSON is quickly becoming the primary choice for developers for consuming and creating web services. Currently, Java applications use different implementation libraries to produce/consume JSON. These libraries are bundled along with the application, thereby increasing the overall size of the deployed archive. Java API for JSON Processing will provide a standard API to parse and generate JSON so that the applications ...

Get Java EE 7 Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.