note 87596 added to function.json-decode

From: Date: Fri, 12 Dec 2008 08:33:38 +0000
Subject: note 87596 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-148057@lists.php.net to get a copy of this message
@giunta dot gaetano at sea-aeroportimilano dot it The spec states, in entirety, that: " A JSON text is a sequence of tokens. The set of tokens includes six structural characters, strings, numbers, and three literal names. A JSON text is a serialized object or array. " This implies dual definition. It is BOTH. The php version of json_decode does fully implement the json spec in this regard. HOWEVER, there is a problem with the value returned when the input is 'null' (ex. json_decode('null') ). Because the return value on failure is also NULL, this makes the json_decode function unreliable in the case of JSON null being supplied. You might not be in control of the API returning the value, and perhaps there is a bug in it that causes this "error", so this is quite a problem. RE: steven at acko dot net The bug you mentioned has been patched, in that inconsistencies are properly handled, but the problem I mention above will probably still exist after the next version release, so becareful people. I asked for the function to throw excpetion or (at least) warning. We'll see where that goes. Some kind of NON value must be used in order to reliably use this function. ---- Server IP: 69.147.83.197 Probable Submitter: 98.247.207.131 ---- Manual Page -- http://www.php.net/manual/en/function.json-decode.php Edit -- https://master.php.net/note/edit/87596 Del: integrated -- https://master.php.net/note/delete/87596/integrated Del: useless -- https://master.php.net/note/delete/87596/useless Del: bad code -- https://master.php.net/note/delete/87596/bad+code Del: spam -- https://master.php.net/note/delete/87596/spam Del: non-english -- https://master.php.net/note/delete/87596/non-english Del: in docs -- https://master.php.net/note/delete/87596/in+docs Del: other reasons-- https://master.php.net/note/delete/87596 Reject -- https://master.php.net/note/reject/87596 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148057) next »