note 118941 added to function.json-decode

From: Date: Thu, 03 Mar 2016 12:35:55 +0000
Subject: note 118941 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-205089@lists.php.net to get a copy of this message
It seems that json_decode will return a Syntax Error when the JSON string has previsouly been filtered. For example: $string = '{"x":"y"'; $filteredString = filter_var($string, FILTER_SANITIZE_STRING); var_dump(json_decode($filteredString,true)); // NULL var_dump(json_last_error_msg()); // string(12) "Syntax error" var_dump(json_decode($string,true)); // array(1) { ["x"]=>string(1) "y" } ---- Server IP: 72.52.91.14 Probable Submitter: 194.255.110.2 ---- Manual Page -- http://php.net/manual/en/function.json-decode.php Edit -- https://master.php.net/note/edit/118941 Del: integrated -- https://master.php.net/note/delete/118941/integrated Del: useless -- https://master.php.net/note/delete/118941/useless Del: bad code -- https://master.php.net/note/delete/118941/bad+code Del: spam -- https://master.php.net/note/delete/118941/spam Del: non-english -- https://master.php.net/note/delete/118941/non-english Del: in docs -- https://master.php.net/note/delete/118941/in+docs Del: other reasons-- https://master.php.net/note/delete/118941 Reject -- https://master.php.net/note/reject/118941 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205089) next »