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

 ID:                 52829
 Updated by:         ka...@php.net
 Reported by:        pzbowen at gmail dot com
 Summary:            json_decode looses data
 Status:             Open
 Type:               Bug
 Package:            JSON related
 Operating System:   Linux
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

I can't see any really easy way to achieve this since properties and
array keys are unique in PHP. Perhaps some overloading with objects but
that would be dirty/hackish


Previous Comments:
------------------------------------------------------------------------
[2010-09-13 20:31:49] pzbowen at gmail dot com

Description:
------------
According to RFC 4627, section 2.2, "The names within an object SHOULD
be unique."  This is only a SHOULD not a MUST, so the following is
valid



{"foo":2,"foo":3}



Unfortunately in PHP this only returns the last object member.

Test script:
---------------
var_dump(json_decode('{"foo":2,"foo":3}'));



Expected result:
----------------
an object with a way of accessing both members or an error raised by
json_decode

Actual result:
--------------
object(stdClass)#1 (1) {

  ["foo"]=>

  int(3)

}


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



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

Reply via email to