JSON - Javascript Object Notation

by Geethalakshmi 2008-11-22 17:14:53

JSON - Javascript Object Notation


>> JSON, short for JavaScript Object Notation, is a lightweight computer data interchange format. It is a text-based, human-readable format for representing simple data structures and associative arrays (called objects).

>> The official Internet media type for JSON is application/json. The JSON file extension is .json.

>> Its main application is in Ajax web application programming, where it serves as an alternative to the use of the XML format.

>> The json.org website provides a comprehensive listing of existing JSON bindings, organized by language.

Data types, syntax and example

JSON's basic types are:

* 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)
* Object (collection of key:value pairs, comma-separated and enclosed in curly braces)
* null

{
"menu": "File",
"commands": [
{
"title": "New",
"action":"CreateDoc"
},
{
"title": "Open",
"action": "OpenDoc"
},
{
"title": "Close",
"action": "CloseDoc"
}
]
}

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, contains an object representing the person's address, and contains a list of phone numbers (an array).

{
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
"212 555-1234",
"646 555-4567"
]
}

Tagged in:

500
like
0
dislike
0
mail
flag

You must LOGIN to add comments