Bug #71718 [Opn->Nab]: json_decode produce error when decoding null
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)