What is JSON?
According to IT Wiki, JSON (/ˈdʒeɪsən/), or JavaScript Object Notation, is a text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages.
The JSON format was originally specified by Douglas Crockford, and is described in RFC 4627. The official Internet media type for JSON is application/json. The JSON filename extension is .json.
The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML.
Data types, syntax and example
JSON’s basic types are:
Number (double precision floating-point format in JavaScript, generally depends on implementation)
String (double-quoted Unicode, with backslash escaping)
Boolean (true or false)
Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type)
Object (an unordered collection of key: value pairs with the ‘:’ character separating the key and the value, comma-separated and enclosed in curly braces; the keys must be strings and should be distinct from each other)
null (empty)
Non-significant white space may be added freely around the “structural characters” (i.e. the brackets “[{]}”, colon “:” and comma “,”).
The following example shows the JSON representation of an object that describes a person. The object has string fields for first name and last name, a number field for age, contains an object representing the person’s address, and contains a list (an array) of phone number objects.
{ "firstName": "John", "lastName": "Doe", "age": 45, "address": { "streetAddress": "21 Vinson Street", "city": "New York", "state": "NY", "postalCode": "10251" }, "phoneNumber": [ { "type": "home", "number": "123 456-7899" }, { "type": "fax", "number": "123 456-7889" } ] }