create and parse JSON data

Following is the PHP code to create the JSON data format of above example using array of PHP. Below that is the code that will parse the JSON data into PHP arrays.

create JSON data format
$json_data = array (\'id\'=>1,\'name\'=>\"rolf\",\'country\'=>\'russia\',\"office\"=>array(\"google\",\"oracle\"));
echo json_encode($json_data);

parse JSON data into PHP arrays
$json_string=\'{\"id\":1,\"name\":\"rolf\",\"country\":\"russia\",\"office\":[\"google\",\"oracle\"]} \';
$obj=json_decode($json_string);
print the parsed data
echo $obj->name; displays rolf
echo $obj->office[0]; displays google