From:             ygbr at me dot com
Operating system: Linux Debian Lenny
PHP version:      5.3.1
PHP Bug Type:     Unknown/Other Function
Bug description:  json_decode returns false when leading zeros aren't escaped 
with double quotes

Description:
------------
When parsing a JSON Payload containing integers or floats with leading 
zeros as values which haven't been escaped using double quotes, 
json_decode() returns false.

Even thought leading zeros are ( most of the times ) irrelevant for 
integers, the function should at least trim the zeros out and not fail 
the entire decoding process. JSON returned from some Java JSON 
generators come with integers containing leading zeros and not escaped 
by double quotes.

Reproduce code:
---------------
<?php

$payload = <<<payload
{
  "test" : 06
}
payload;

if(!$obj = json_decode($payload)) die("Problems on JSON Parsing the
json_decode() function has returned false");

print_r($obj);

Expected result:
----------------
stdClass Object ( [test] => 6 )

Actual result:
--------------
Problems on JSON Parsing the json_decode() function has returned false

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

Reply via email to