From: Operating system: Gentoo Linux x86 PHP version: 5.3.6 Package: JSON related Bug Type: Bug Bug description:json_decode skips value where json_encode includes it
Description:
------------
If you have empty array inside object, json_encode() does encode the value
into JSON format, but when the data is decoded with json_decode(), this
empty JSON array is omitted from output.
Consider following structure:
["timetable"]=>
object(pizzaonline\model\Timetable)#30 (9) {
["id"]=>
string(3) "774"
["timetable"]=>
array(0) {
}
["opening_hours"]=>
..
Corresponding json_encode would be:
"timetable":{
"id":"774",
"timetable":[
],
"opening_hours":[
..
This is all right, but I have a loop that removes this empty array with
unset(). So PHP structure from JSON is encoded is like:
["timetable"]=>
object(pizzaonline\model\Timetable)#30 (8) {
["id"]=>
string(3) "774"
["opening_hours"]=>
But using json_encode() returns same result that is in snippet 2.
Just ask if any questions, Iâll do example script later...
--
Edit bug report at http://bugs.php.net/bug.php?id=54513&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54513&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54513&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54513&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54513&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54513&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54513&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54513&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54513&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54513&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54513&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54513&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54513&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54513&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54513&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54513&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54513&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54513&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54513&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54513&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54513&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54513&r=mysqlcfg
