#47349 [Opn]: Seriliazing and Unserializing and obj breaks numeric keys

From: Date: Mon, 09 Feb 2009 14:49:18 +0000
Subject: #47349 [Opn]: Seriliazing and Unserializing and obj breaks numeric keys
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133642@lists.php.net to get a copy of this message
ID: 47349 User updated by: darren at viamedia dot co dot za Reported By: darren at viamedia dot co dot za Status: Open Bug Type: Class/Object related Operating System: Ubuntu PHP Version: 5.2CVS-2009-02-09 (snap) New Comment: JSON ENCODE AND DECODE WORK AS I WOULD EXPECT SERIALIZE AND UN-SERIALIZE TO WORK $test = new stdClass(); $Id = 12; $test->$Id = new stdClass(); $test->$Id->value = 12; $Id = '23'; $test->$Id = new stdClass(); $test->$Id->value = '23'; var_dump($test); $ser = json_encode($test); $unser = json_decode($ser); echo '<hr />'; var_dump($unser); die('die'); Previous Comments: ------------------------------------------------------------------------ [2009-02-09 14:10:18] darren at viamedia dot co dot za Description: ------------ Numeric Id keys for stdObj are lost after serializing and unseriliazing Reproduce code: --------------- $test = new stdClass(); $Id = 12; $test->$Id = new stdClass(); $test->$Id->value = 12; $Id = '23'; $test->$Id = new stdClass(); $test->$Id->value = '23'; var_dump($test); $ser = serialize($test); $unser = unserialize($ser); echo '<hr />'; var_dump($unser); die('die'); Expected result: ---------------- I would expect both dumps to be the same and the numeric Id keys be there after serializing Actual result: -------------- After serializing and Unserializing the numeric Id keys are lost ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47349&edit=1

« previous php.bugs (#133642) next »