Showing posts with label json Objects. Show all posts
Showing posts with label json Objects. Show all posts

Tuesday 24 July 2012

What is JSON?

JSON is JavaScript Object Notation. It is a lightweight data-interchange format and language independent also. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript etc. These properties make JSON an ideal data-interchange language.


JSON data comes in two structures
  1. Name/Value pairs   
  2. An ordered list of values
These are universal data structures. Virtually all modern programming languages support them in one form or another.
JSON value can be string, number, null, array, object.
JSON data can one of these form(s).


Name/Value pair
JSON data is written as name/value pairs.
A name/value pair consists of a field name in double quotes, followed by a colon, followed by a value.
e.g. "age" : "28"


JSON Objects
JSON objects are written inside curly brackets,
Objects can contain multiple name/values pairs:
e.g. { "Name":"John" , "age":"28" } 


JSON Arrays
JSON arrays are written inside square brackets.
An array can contain multiple objects:
e.g. {
"employees": 
            [
{ "Name":"John" , "age":"28" },
{ "Name":"mick" , "age":"23" }
          ]
       }


The MIME type for JSON text is "application/json".