note 75348 added to function.json-decode
| From: | phpben at hood dot id dot au | Date: | Fri, 25 May 2007 02:43:22 +0000 |
| Subject: | note 75348 added to function.json-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126881@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 203.16.234.91
Probable Submitter: 210.15.202.115
----
Manual Page -- http://www.php.net/manual/en/function.json-decode.php
Edit -- https://master.php.net/note/edit/75348
Del: integrated -- https://master.php.net/note/delete/75348/integrated
Del: useless -- https://master.php.net/note/delete/75348/useless
Del: bad code -- https://master.php.net/note/delete/75348/bad+code
Del: spam -- https://master.php.net/note/delete/75348/spam
Del: non-english -- https://master.php.net/note/delete/75348/non-english
Del: in docs -- https://master.php.net/note/delete/75348/in+docs
Del: other reasons-- https://master.php.net/note/delete/75348
Reject -- https://master.php.net/note/reject/75348
Search -- https://master.php.net/manage/user-notes.php