php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65982 json_decode null result error
Submitted: 2013-10-28 12:51 UTC Modified: 2014-05-08 16:24 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: info at djdb dot be Assigned:
Status: No Feedback Package: json (PECL)
PHP Version: 5.4.21 OS: win
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: info at djdb dot be
New email:
PHP Version: OS:

 

 [2013-10-28 12:51 UTC] info at djdb dot be
Description:
------------
---
From manual page: http://www.php.net/function.json-decode
---
when use json_decode in object (class) the function wil not works an gives a NULL

Test script:
---------------
    $string = '{"foo": "bar", "cool": "attr"}';
    $result = json_decode($string, true);
     
    // Result: array(2) { ["foo"]=> string(3) "bar" ["cool"]=> string(4) "attr" }
    var_dump($result);   


 class AddressWebservice_of_json extends AddressWebservice_of{
            public function __construct($debug=false,$IncERRORresolve){
                parent::__construct($debug=false,$IncERRORresolve);
            }
            /**
             * AddressWebservice_of::getresult()
             * @param mixed $aso 
             * @return void
             */
            public function getjsonresult(&$string){
                
                    
                $array = json_decode($string,true);
                var_dump($array);
                //$res =  parent::getresult("egon","","","","","","","");
                return json_encode($res);
            }
            /**
             * AddressWebservice_of::setRemotservices()

             * @return void
             */
            public function setRemotservices($asoArray){
                $this->list = $asoArray;
            }
    }

Expected result:
----------------
null @var_dump($array);

Actual result:
--------------
array()

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-29 08:08 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2013-10-29 08:08 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

That class is clearly part of a larger system. We need something smaller that we can execute that shows the problem, not to mention the actual values being passed around.
 [2014-05-08 16:24 UTC] ab@php.net
-Status: Feedback +Status: No Feedback
 [2014-05-08 16:24 UTC] ab@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.

Also, from your code

                //$res =  parent::getresult("egon","","","","","","","");
                return json_encode($res);

$res is undefined
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC