note 97742 deleted from function.json-decode by googleguy
| From: | googleguy@php.net | Date: | Fri, 30 Nov 2012 05:42:11 +0000 |
| Subject: | note 97742 deleted from function.json-decode by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192215@lists.php.net to get a copy of this message | ||
Note Submitter: Mitchell Simoens
----
In my case, I was passing simple JSON in the URL...
eg myfile.php?test=["one", "two", "three"]
but I kept getting NULL no matter what I tried. I did a simple echo of $_REQUEST["test"]
and noticed that the browser added the "\" to the double-quotes. I had to prepare the data
first then do the decode:
<?php
$data = str_replace("\\", "", $_REQUEST["test"]);
$results = json_decode($data);
?>
This produced what was expected