Reading “PHP & jQuery Cookbook” right now and it gives this example for using json_decode()
<?php
$json = <<<JSON
{
"origin":"Delhi",
"destination":"London",
"passengers":
[
{
"name":"Mr. Perry Mason",
"type":"Adult",
"age":28
}
{
"name":"Miss Irene Adler",
"type":"Adult",
"age":25
}
],
"travelDate":"17-Dec-2010"
}
JSON;
$objJson = json_decode($json);
echo ($objJson);
?>
The code just gives me a blank page when I run it. Is there something invalid about that JSON? Because json_decode() doesnt even seem to see it.
rather use print_r() than using echo to see if it prints
but a comma is missing from your JSON input
it should be like this