note 113136 added to function.json-decode

From: Date: Wed, 04 Sep 2013 06:39:29 +0000
Subject: note 113136 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-196156@lists.php.net to get a copy of this message
json_decode can not handle string like:\u0014,it will return null,and with the error <?php json_last_error()=JSON_ERROR_CTRL_CHAR ?> according ascii_class from json module, use the next codes to fix the bug: <?php $str = preg_replace_callback('/([\x{0000}-\x{0008}]|[\x{000b}-\x{000c}]|[\x{000E}-\x{001F}])/u', function($sub_match){return '\u00' . dechex(ord($sub_match[1]));},$str); var_dump(json_decode($str)); ?> ---- Server IP: 220.181.129.130 Probable Submitter: 183.17.169.218 ---- Manual Page -- http://php.net/manual/en/function.json-decode.php Edit -- https://master.php.net/note/edit/113136 Del: integrated -- https://master.php.net/note/delete/113136/integrated Del: useless -- https://master.php.net/note/delete/113136/useless Del: bad code -- https://master.php.net/note/delete/113136/bad+code Del: spam -- https://master.php.net/note/delete/113136/spam Del: non-english -- https://master.php.net/note/delete/113136/non-english Del: in docs -- https://master.php.net/note/delete/113136/in+docs Del: other reasons-- https://master.php.net/note/delete/113136 Reject -- https://master.php.net/note/reject/113136 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196156) next »