|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-10-02 05:52 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2016-10-02 05:52 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 01:00:02 2026 UTC |
Description: ------------ I use json_encode() with a depth (usually 1) to trim complex objects in some test cases in order to do comparisons. But it returns false now if the object being encoded contains a member which is an object. I have to set the depth to 2 but it means it doesn't trim like what I did before. But I'm not sure if this bug is related to PHP 5.6.26. It might have been introduced in earlier versions. Test script: --------------- class Person { public $name; public $age; public $role; } class Role { public $name; } $person = new Person(); $person->name = 'Name'; $person->age = 20; $person->role = new Role(); $jsonObj = json_encode($person, 0, 1); // $jsonObj === false Expected result: ---------------- {"name":"Name","age":20,"role":null} Actual result: -------------- false