Basic concepts of JSON:
WIKIPEDIA: JSON (JavaScript Object Notation), is a lightweight 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 most ages.
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.
JSON is a lightweight data exchange format. Easy for reading and writing, and easy for machine parsing and generation. JSON uses a language-independent text format, but it also uses a style similar to the C language family (including C, C ++, C #, Java, and JavaScript ). These features make JSON an ideal data exchange language. Many languages or libraries provide excellent support for JSON format and facilitate various parsing and operations.
JSON is based on two structures:
1. A collection of name/value pairs. In various versions, this is realized as an object, record, struct, Dictionary, hash table, keyed list, or associative array.
2. An ordered list of values. In most ages, this is realized as an array, vector, list, or sequence.
JSON format rules:
Number (type not specified, but in practice Double Precision Floating-point format, as this is how Javascript in Web browsers treats it)
String (double-quoted Unicode (UTF-8 by default), 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 shoshould be distinct from each other)
Null (empty)
Example of JSON format data:
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.
JSON Sample
{
"firstName": "John",
"lastName" : "Smith",
"age" : 25,
"address" :
{
"streetAddress": "21 2nd Street",
"city" : "New York",
"state" : "NY",
"postalCode" : "10021"
},
"phoneNumber":
[
{
"type" : "home",
"number": "212 555-1234"
},
{
"type" : "fax",
"number": "646 555-4567"
}
]
}