|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-24 16:35 UTC] harald dot lapp at gmail dot com
Description: ------------ Apparently it's impossible to decode strings with escaped "escape" character: \\ this should work however, as it's written in the json specs on http://json.org/ Test script: --------------- <?php var_dump(json_decode('["\\"]', true)); ?> Expected result: ---------------- array(1) { [0]=> string(1) "\" } Actual result: -------------- NULL PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 08:00:01 2025 UTC |
You are confusing PHP escapes and json escapes. Watch: php > $str = '["\\"]'; php > echo $str; ["\"] That's obviously not valid json. What you actually want: php > $str = '["\\\\"]'; php > echo $str; ["\\"] php > var_dump(json_decode($str)); array(1) { [0]=> string(1) "\" } Works fine. No bug here.