Saturday, May 26, 2007

JSON – PHP

JSON (JavaScript Object Notation) is universal data exchange format. JSON is part of ECMA Script Standards. eval() function that can parse this format .This is being popular with the success of AJAX. Another language XML is used for sharing (exchange) data in different platform. But JSON is easier to read than XML for programmer. JSON contain easier structure. JSON can easily map to object-oriented system.

What problem JSON can solve:

“I have a data-structure in one platform, I want to use it to another platform. “—We can use JSON to solve this problem. No need for parsing an XML document to extract the data-structure.

Understanding Literal Notation in JavaScript:

Array literals in JavaScript are composed of zero or more expressions with each expression representing an element of the array. The array elements are enclosed in square brackets ([]) and delimited by commas. Example:

var continents = ["Europe", "Asia", "Australia", "Antarctica", "North
America", "South America", "Africa"];
Compare this now to how you would create and initialize an array in JavaScript without
the literal notation:
var continents = new Array();
continents[0] = "Europe";
continents[1] = "Asia";

continents[2] = "Australia";
continents[3] = "Antarctica";
continents[4] = "North America";
continents[5] = "South America";
continents[6] = "Africa";
An object literal defines the members of an object and their values. The list of object members and values is
enclosed in curly braces ({}) and each member is delimited by a comma. Within each member, the name and value
are delimited by a colon (:).
Example:
var contact = {
"Name": "John Doe",

"PermissionToCall": true,

"PhoneNumbers": [

{

"Location": "Home",

"Number": "555-555-1234"

},

{

"Location": "Work",

"Number": "555-555-9999 Ext. 123"

}

]

};

Example JSON and PHP:

For your assistance,I attached here some sample code.
Those are free. After download you have to extract
download files and
after that run index.html………….