I've got a JSON object that I'm sending to a PHP script and I'm having trouble parsing the JSON. Here's the POST request:
http://mywebsite.com?action=somefunction&{%22id%22:1,%22Name%22:%22Mike%22}
And here's my PHP function, which obviously doesn't work:
$data = $_GET['data'];
$obj = json_decode($data);
echo $obj->Name;
die();
The end goal is to extract the name "Mike" from the URL string. Any suggestions?
Try taking a look at what PHP is outputting from
json_decode()
:Your code itself works fine: http://ideone.com/0jsjgT
But your query string is missing the
data=
before the actual JSON. This:should be this:
you should do
This also is a duplicate question of Echo data json by json_decode