JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and Ruby.
JSON is built on two structures:
A collection of name/value pairs.
An ordered list of values.
JSON is often used to exchange data between a server and a web application. When a web application receives data from a server, it may receive it in JSON format. The web application can then use JavaScript to process the JSON data.
The following example shows how to use the PHP function json_decode() to decode a JSON string and print the results to the screen.
The output of the code above will be:
Array
(
[name] => John
[age] => 30
)