Doc #65907 [Fbk->NoF]: json_decode returns NULL if input is NULL
| From: | php-bugs at lists dot php dot net | Date: | Tue, 30 Dec 2014 10:42:02 +0000 |
| Subject: | Doc #65907 [Fbk->NoF]: json_decode returns NULL if input is NULL | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11789@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65907&edit=1
ID: 65907
Updated by: php-bugs@lists.php.net
Reported by: bsasser at sindtech dot net
Summary: json_decode returns NULL if input is NULL
-Status: Feedback
+Status: No Feedback
Type: Documentation Problem
Package: JSON related
Operating System: Linux/GNU
PHP Version: Irrelevant
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2013-11-01 05:20:10] yohgaki@php.net
I guess you are using Debian or Ubuntu aren't you?
IIRC, there is similar bug reports from these OS users.
BTW, my PHP from Fedora 19 returns null/true/false as expected.
------------------------------------------------------------------------
[2013-10-16 00:36:13] bsasser at sindtech dot net
Description:
------------
---
From manual page: http://www.php.net/function.json-encode#refsect1-function.json-encode-returnvalues
---
It states "Return Values
Returns a JSON encoded string on success or FALSE on failure."
Except, when input is NULL, it returns NULL, not FALSE.
Ref. bug #49588 where the following comment is made:
" [2012-07-02 16:58 UTC] gudjonj at gmail dot com
To return null if encoding is incorrect makes no sense."
This is not a duplicate - this is expressly for NULL as input (all other bug reports involve special
characters/local issues). However, the comment is correct - returning NULL [for any reason] if
encoding makes no sense.
Test script:
---------------
$a = NULL;
$b = FALSE;
$c = array("Hello","world!");
var_dump(json_encode($a));
var_dump(json_encode($b));
var_dump(json_encode($c));
Expected result:
----------------
When encoding NULL, FALSE is the expected output (not just because it makes sense, but because the
documentation says so ;-) ).
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65907&edit=1