Could you please tell me, what is the use of JSON (in Javascript and PHP). when we need a JSON method.
I read from the following link but, i didn't get any information regarding the JSON implementation on any project.
Could you please tell me, what is the use of JSON (in Javascript and PHP). when we need a JSON method.
I read from the following link but, i didn't get any information regarding the JSON implementation on any project.
JSON is mostly used as a lightweight and more human readable alternative to XML in AJAX web apps.
All of the other answers are great, but perhaps the simplest explanation for your specific case (JavaScript + PHP): JSON is the easiest way to translate a JavaScript object into a PHP associative array or object (and vice-versa).
Take a look at json_encode() and json_decode() for the PHP side of things. On the JavaScript side, a simple eval() is the easiest (but least-safe!) way to get an object out of a JSON string, but your library of choice will certainly have functions to take care of this for you, and if you're targeting newer browsers you can use the ECMAScript 5 JSON object.
Despite its name, one of the primary uses of the JSON format is in AJAX web development (though certainly not the only one). It is often preferred over the traditional XML for its light-weight syntax.