note 113137 added to function.json-decode

From: Date: Wed, 04 Sep 2013 06:39:51 +0000
Subject: note 113137 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-196157@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/113137 Del: integrated -- https://master.php.net/note/delete/113137/integrated Del: useless -- https://master.php.net/note/delete/113137/useless Del: bad code -- https://master.php.net/note/delete/113137/bad+code Del: spam -- https://master.php.net/note/delete/113137/spam Del: non-english -- https://master.php.net/note/delete/113137/non-english Del: in docs -- https://master.php.net/note/delete/113137/in+docs Del: other reasons-- https://master.php.net/note/delete/113137 Reject -- https://master.php.net/note/reject/113137 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196157) next »