From:             
Operating system: Linux
PHP version:      5.2.14
Package:          JSON related
Bug Type:         Bug
Bug description:json_decode looses data

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 bug report at http://bugs.php.net/bug.php?id=52829&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52829&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52829&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52829&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52829&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52829&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52829&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52829&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52829&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52829&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52829&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52829&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52829&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52829&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52829&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52829&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52829&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52829&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52829&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52829&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52829&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52829&r=mysqlcfg

Reply via email to