json_decode

json_decode:- It is used for decoding JSON in PHP. This function returns the value decoded from json to appropriate PHP type.

Syntax:-
mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )

Parameters:-
(i) json :- The json string being decoded. This function only works with UTF-8 encoded data.
(ii) assoc:- When TRUE, returned objects will be converted into associative arrays.
(iii) depth:- User specified recursion depth.
(iv) options:- Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRING is supported (default is to cast large integers as floats).

Example:-
[php]
<?php
$jsonData = ‘{ "user":"John", "age":26, "country":"India" }’;
$phpArray = json_decode($jsonData);
print_r($phpArray);
foreach ($phpArray as $key => $value) {
echo $key .’|’. $value";
}
?>[/php]
Output:- stdClass Object ( [user] => John [age] => 26 [country] => India )
Output:- user | John
Output:- age | 26
Output:- country | India