Wednesday, July 29, 2009

JSON with example

GO THRO' IT:

JSON (JavaScript Object Notation):
- A lightweight data-interchange format.

- Easy for humans to read and write.

- Easy for machines to parse and generate

JSON is built on two data structures:
- A collection of name/value pairs (unordered structure).

- An ordered list of values.
JSON's basic types:
  • Number (integer, real, or floating point)
  • String (double-quoted Unicode with backslash escaping)
  • Boolean (true and false)
  • Array (an ordered sequence of values, comma-separated and enclosed in square brackets)
  • Hashtable or Map (collection of key: value pairs, comma-separated and enclosed in curly braces)
  • null
Sample JSON Format:

{

“firstname”:”John”,
“lastname”:”Smith”,
“address”:{

“streetaddress”:”21,2nd Street”,
“city”:”Chennai”,
“state”:”TN”,
“postalcode”:”600090”
},
“phonenumbers”:[

“044-22772299”,
“044-28888888”]

}

>>The above example explain the JSON representation of an object that describes a person. The object has string fields for first name and last name, contains an object representing the person's address, and contains a list of phone numbers (an array).
>>It is based on a subset of the JavaScript Programming Language,ECMA-262 3rd Edition - December 1999.

Thanks
A.T.J

1 comment: