note 103438 modified in function.json-decode by danbrown

From: Date: Wed, 13 Apr 2011 16:04:31 +0000
Subject: note 103438 modified in function.json-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178799@lists.php.net to get a copy of this message
There is a problem when passing to json_decode a string with the "\" symbol. It seems to identify it as an escape character and trying to follow it. So sometimes it leads to failed parsing. It seems that just replacing it with "\\" helps. <?php print_r(json_decode(str_replace('\\', '\\\\', '{"name":"/\"}'))); ?> where /\ is the string which doesn't worked. --was-- There is a problem when passing to json_decode a string with the "\" symbol. It seems to identify it as an escape character and trying to follow it. So sometimes it leads to failed parsing. It seems that just replacing it with "\\" helps. <? print_r(json_decode(str_replace('\\', '\\\\', '{"name":"/\"}'))); ?> where /\ is the string which doesn't worked. http://php.net/manual/en/function.json-decode.php

« previous php.notes (#178799) next »