JSON stands for JavaScript Object Notation.
JavaScript Object Notation (JSON) is a lightweight data-interchange format inspired by the object literals of JavaScript. JSON values can consist of:
- objects (collections of name-value pairs)
- arrays (ordered lists of values)
- strings (in double quotes)
- numbers
- true, false, or null.
The decoding is handled by a parser based on the JSON_checker by Douglas Crockford.
JSON encode/decode functions have been available in PHP since version 5.2. JavaScript’s JSON stringify/parse methods are supported by all current browsers.JSON libraries and/or built-in support are provided for many other programming languages as well.
When passing data from PHP to JavaScript, the PHP json_encode function is used to return a string containing the JSON equivalent of the value passed to it. A User can then use the JavaScript JSON.parse method to safely handle the data and make it available in a form usable by JavaScript.
There are different types of function are present in JSON:
- json_decode — This function is used to decodes a JSON string.
- json_encode — This function is used to return the JSON representation of a value.
- json_last_error_msg — This function is used to returns the error string of the last json_encode() or json_decode()call.
- json_last_error — This function is used to returns the last error occurred.