php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71718 json_decode produce error when decoding null
Submitted: 2016-03-05 17:19 UTC Modified: 2016-03-05 17:46 UTC
From: noskov dot vlad at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 7.0.4 OS: Darwin Kernel Version 15.3.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: noskov dot vlad at gmail dot com
New email:
PHP Version: OS:

 

 [2016-03-05 17:19 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-05 17:46 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2016-03-05 17:46 UTC] nikic@php.net
This is an intentional change. null interpreted as a string is "", and that's not valid JSON.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 01:01:30 2024 UTC