note 89122 added to function.json-decode
| From: | iisfirewall at 126 dot com | Date: | Mon, 23 Feb 2009 06:15:51 +0000 |
| Subject: | note 89122 added to function.json-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151005@lists.php.net to get a copy of this message | ||
eg1:
$json = '
{
"iisuser.com":"A\\B"
}
';
var_dump(json_decode($json, true));
result:
===================================
string(29) " { "iisuser.com":"A\B" } "
===================================
look at: string not a array
my version: 5.2.6
so the right way is:
add one \ to \\ it become:
$json = '
{
"iisuser.com":"A\\\B"
}
';
var_dump(json_decode($json, true));
===================================
array(1) { ["iisuser.com"]=> string(3) "A\B" }
===================================
why? \\ in string,it is will be \,but it is in '........'
then json_decode will do the same action!
from www.iisuser.com
----
Server IP: 221.194.139.225
Probable Submitter: 218.89.192.58
----
Manual Page -- http://www.php.net/manual/en/function.json-decode.php
Edit -- https://master.php.net/note/edit/89122
Del: integrated -- https://master.php.net/note/delete/89122/integrated
Del: useless -- https://master.php.net/note/delete/89122/useless
Del: bad code -- https://master.php.net/note/delete/89122/bad+code
Del: spam -- https://master.php.net/note/delete/89122/spam
Del: non-english -- https://master.php.net/note/delete/89122/non-english
Del: in docs -- https://master.php.net/note/delete/89122/in+docs
Del: other reasons-- https://master.php.net/note/delete/89122
Reject -- https://master.php.net/note/reject/89122
Search -- https://master.php.net/manage/user-notes.php