Edit report at http://bugs.php.net/bug.php?id=53291&edit=1

 ID:                 53291
 Updated by:         cataphr...@php.net
 Reported by:        pwinnski at gmail dot com
 Summary:            json_encode throws away array elements with an empty
                     string for a key
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            JSON related
 Operating System:   Linux
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

I can't reproduce this in PHP 5.2.14:



r...@router:~# php -v

PHP 5.2.14 (cli) (built: Aug 18 2010 17:16:15)

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

r...@router:~# php

<?php

dl("json.so");

var_dump(json_encode(array("" => array("a" => 1))));

string(12) "{"":{"a":1}}"



But even if there was actually a bug, PHP 5.2 is only to receive
security updates at this point. So Bogus/Wont Fix.


Previous Comments:
------------------------------------------------------------------------
[2010-11-10 16:42:42] pwinnski at gmail dot com

Description:
------------
In 5.2.14, json_encode() silently discards any array values for which
the array 

key is an empty string. This seems identical to Bug #41505, but affects
PHP 

5.2.14.



Demonstration code:

var_dump(json_encode(array("" => array("a" => 1))));



Expect (result in 5.2.6, 5.2.10, 5.2.13, 5.3.2):

string(12) "{"":{"a":1}}"



Receive (in 5.2.14):

string(2) "{}"

Test script:
---------------
var_dump(json_encode(array("" => array("a" => 1))));

Expected result:
----------------
string(12) "{"":{"a":1}}"

Actual result:
--------------
string(2) "{}"


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53291&edit=1

Reply via email to