Bug #71718 [Opn->Nab]: json_decode produce error when decoding null

From: Date: Sat, 05 Mar 2016 17:46:58 +0000
Subject: Bug #71718 [Opn->Nab]: json_decode produce error when decoding null
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199610@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71718&edit=1

 ID:                 71718
 Updated by:         nikic@php.net
 Reported by:        noskov dot vlad at gmail dot com
 Summary:            json_decode produce error when decoding null
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            JSON related
 Operating System:   Darwin Kernel Version 15.3.0
 PHP Version:        7.0.4
 Block user comment: N
 Private report:     N

 New Comment:

This is an intentional change. null interpreted as a string is "", and that's not
valid JSON.


Previous Comments:
------------------------------------------------------------------------
[2016-03-05 17:19:47] noskov dot vlad at gmail dot com

Description:
------------
Starting from v.7.0  after calling json_decode(null), json_last_error() return JSON_ERROR_SYNTAX.
For earlier versions it return 0.

https://3v4l.org/VSIXH

Test script:
---------------
<?php

json_decode(null);
var_dump(json_last_error());

Expected result:
----------------
json_last_error() return 0

Actual result:
--------------
json_last_error() return JSON_ERROR_SYNTAX


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71718&edit=1


Thread (2 messages)

« previous php.bugs (#199610) next »