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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2018 The PHP Group
All rights reserved.
Last updated: Sat Nov 17 02:01:25 2018 UTC