What is JSON?
JavaScript Object Notation or JSON is a text-notation format for the serialization of structured data. The JSON format describes how to represent and structure the data so that it can easily written, transferred and parsed by the receiver. JSON is easy for humans to read and write. It’s also easy for machines to programmatically parse and generate. By looking at a document structured using the JSON format, one can visually read the data and the structure of the data, such as how data is related to other data parent or child item. This ease of use has made JSON one of the most popular ways to format and interchange data.
The reason one might use the JSON format to structure their data is to provide for ease of serialization. That means the data can easily be translated from an object into a format that can be stored (for example, in a file) or transmitted (for example, across a network). JSON can represent four primitive data types: String, Number, Boolean and Null, as well as two structured types: Object and Array.
The JSON format is an open-standard file format, meaning that whoever is reading and writing JSON must adhere to the standard. This standardization makes JSON a great choice for how to format your data when communicating data between two systems, such as an API and a client or a web server and client.
A Brief History of JSON and its rise to popularity
JSON is language independent, but was derived from the ECMAscript programming language standard (Javascript is based on this standard as well) and its object notation. Many programming languages besides javascript have the ability to create and parse JSON. This means JSON can be written in one programming environment and parsed, or read, by another programming environment.
JSON was originally created by Douglas Crockford and his team at State Software in the early 2000s as a lightweight alternative to XML (Extensible Markup Language). Json.org was launched in 2002 to describe the format, and Crockford specified the format officially in RFC-4627 in 2006.
Today, JSON usage and developer interest is on the rise while XML usage is declining. Of the top ten most popular web APIs according to the Programmable Web, only one supports XML and not JSON: Amazon Product Advertising API. Several of the most popular web APIs support both, and several support only JSON: Facebook Graph API, Google Maps API, Twitter API, AccuWeather API, Pinterest API, Reddit API, Foursquare API. (source).
Usage:
As mentioned on json.org, 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.
When combined with the dynamic web page technology Ajax (Asynchronous Javascript and XML), the JSON data format allows structured data to be passed seamlessly between a web server and the browser, which in turn can update the browser to show information from a web server without reloading the web page. This popular combination of technologies allows for a seamless user experience.
JSON as a data-interchange format promises interoperability, openness and ease of use. While JSON is completely independent of any programming language, its conventions and data structure format maps effortlessly to object-oriented languages and should be familiar to developers using popular languages such as Javascript, Ruby, Java and Python. In fact, JSON is built into the programming languages Javascript and Python. In Ruby, the JSON module is available in the Standard Library which comes packaged with the Ruby language, which means to start using JSON in Ruby, simply require ‘JSON` within a ruby file. To make JSON available to Java, one simply needs a package of three classes that is available for free from json.org.
There are many similarities to Javascript’s standards for defining an object, and there are also a few differences. Douglas Crockford intended for JSON to be a subset of javascript, but there are a few data portability issues which result in valid JSON to be invalid javascript. In the opposite case, not every valid javascript declaration is valid JSON. JSON has stricter rules for the use of quotes, data types and the grammar of representing Numbers. For example, in JSON, all keys must be within quotes, whereas within a javascript object literal, quotes are not necessary.