php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72217 json_decode not working correctly.
Submitted: 2016-05-14 10:20 UTC Modified: 2016-05-15 15:20 UTC
From: b dot bendeliani at gmail dot com Assigned:
Status: Duplicate Package: JSON related
PHP Version: 7.0.6 OS: CentOS
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: b dot bendeliani at gmail dot com
New email:
PHP Version: OS:

 

 [2016-05-14 10:20 UTC] b dot bendeliani at gmail dot com
Description:
------------
I'm had this script in older version of php and there was not any error. When I upgraded to PHP 7.0.6 this problem occurred. 

Test script:
---------------
class Json implements JsonSerializable
{
    public function jsonSerialize()
    {
        json_decode("");

        return ["test" => "test"];
    }
}

$test = new Json;

header('Content-Type: application/json');
echo json_encode($test);


Expected result:
----------------
{"test":"test"}

Actual result:
--------------
""

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-14 10:24 UTC] b dot bendeliani at gmail dot com
-Summary: json_decode now working correctly. +Summary: json_decode not working correctly.
 [2016-05-14 10:24 UTC] b dot bendeliani at gmail dot com
spelling correction.
 [2016-05-15 15:09 UTC] bukka@php.net
-Package: json +Package: JSON related
 [2016-05-15 15:19 UTC] bukka@php.net
-Status: Open +Status: Duplicate
 [2016-05-15 15:19 UTC] bukka@php.net
This is duplicate (from the internal point of view) of https://bugs.php.net/bug.php?id=72069 and it has been fixed by https://github.com/php/php-src/commit/589d0e0f187ff82f90110057f624c958f0d3ec86 .
 [2016-05-15 15:20 UTC] bukka@php.net
Should be part of 7.0.7
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 14:01:27 2025 UTC