note 75348 deleted from function.json-decode by danbrown
| From: | danbrown@php.net | Date: | Sat, 02 May 2009 14:55:57 +0000 |
| Subject: | note 75348 deleted from function.json-decode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154143@lists.php.net to get a copy of this message | ||
Note Submitter: phpben at hood dot id dot au
----
whatifif at yahoo dot com said something about a bug:
"When I try to decode JSON string {"a":"<p>test</p>"} into
array on server-side, it fails."
That is not a valid JSON string, AFAICT. The JSON docs seem to say that
'"','/' and '\' must be quoted with a '\'
$ php -r 'echo json_encode("<p>test</p>");'
"<p>test<\/p>"
So it was your '/' character screwing it over.
You probably shouldn't blindly run stripslashes on your $input either! The only time you would
is if magic_quotes_gpc is turned on and your string is coming from one of the GPC.
I inherited some PHP code which used Services_JSON. It stopped working when we upgraded PHP and
started using this function. The problem was they ran html_entity_decode() over the input and
was being turned into a character incompatible with UTF-8.