Jab Jab - 3 years ago 149
JSON Question

Passing json object as url parameter

$jsonData = array(
"comments" => "Fresh food",
"container" => false,
"cookedTime" => 2,
"description" => "biryani",
"refridgeration" => true,
"serves" => 2,
"veg" => true


This is my php page which contains json object. I am passing this json object into another page Post.php.

$jsonData = $_GET['json'];
json_decode($jsonData, TRUE);
echo var_dump($jsonData);

when I did a dump the result is C:\wamp\www\Hack\Post.php:16:string 'Array' (length=5).
It is printing "Array" instead of the json object. What do I do?

Answer Source

When you do json_encode you must have a variable to store the result:

$jsonData = json_encode($jsonData)

Without this, your data is still just a php object

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download