|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-27 16:32 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 07:00:02 2025 UTC |
Description: ------------ The json_encode() function completely ignores, and thus does not encode, PHP array entries with an array key that is an empty string: array (""=>"value"); Empty string array keys and object properties are totally valid PHP and JSON respectively - they should encode/decode as such. This, along with the corresponding json_decode() bug of a similar nature (41504), are show stoppers for me as I need JSON encode/decode to be rock solid and consistent. Thanks for looking into this :-) Reproduce code: --------------- 1) var_dump(json_encode(array(""=>"value"))); 2) var_dump(json_encode(array(""=>"value1", "key2"=>"value2"))); Expected result: ---------------- 1) string(15) "{"":"value"}" 2) string(17) "{"":"value1", "key2":"value2"}" Actual result: -------------- 1) string(2) "{}" 2) string(17) "{"key2":"value2"}" In both cases the array entry with the empty string key is missing. This might be addressed by Bug #41034, but may very well be a different bug.