JSON- JavaScript Object Notation

JSON- JavaScript Object NotationJSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format based on the object notation of the JavaScript language. It does not require JavaScript to read or write; it is easy to parse by any language and libraries and tools exist in many languages to handle JSON.

It is:

  • easy for humans to read and write
  • easy for machines to parse and generate
  • based on a subset of the JavaScript Programming Language
  • text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages

JSON is built on two structures:
1. A collection of name/value pairs- something analogous to Objects, structs, hash table, keyed list, dictionary
2. An ordered list of values- realised as an array, vector, list or sequence

In JSON the universal data structures take on these forms:
Object: An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).

Array: An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).

Value: A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

String: A string is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.

Number: A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.

An JSON Example:

{“menu”: {
“id”: “file”,
“value”: “File”,
“popup”: {
“menuitem”: [
{“value”: “New”, “onclick”: “CreateNewDoc()”},
{“value”: “Open”, “onclick”: “OpenDoc()”},
{“value”: “Close”, “onclick”: “CloseDoc()”}
]
}
}}

The same text in XML:
<menu id=”file” value=”File”>
<popup>
<menuitem value=”New” onclick=”CreateNewDoc()” />
<menuitem value=”Open” onclick=”OpenDoc()” />
<menuitem value=”Close” onclick=”CloseDoc()” />
</popup>
</menu>

For more Examples here

Articles related to XML and JSON:
JSON and XML (Link)
The JSON vs XML debate begins in earnest (Link)
Using JSON with Yahoo! Web services (Link)
Using JSON with Google Data APIs (Link)

Source- JSON.org (Link)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s