From:             
Operating system: FreeBSD
PHP version:      5.3.8
Package:          JSON related
Bug Type:         Bug
Bug description:JSON_NUMERIC_CHECK option mangles certain values

Description:
------------
json_encode will produce undesired results when used with
JSON_NUMERIC_CHECK when one or more values is longer than 12 digits, ex:
3434343434343434. The resulting JSON encoded string has the above value
listed as: 3434343434340000.

Removing the JSON_NUMERIC_CHECK option fixes the problem, but then all
other numeric values are returned as strings rather than integers.



Test script:
---------------
$test = array("test"=>3434343434343434);

$test = json_encode($test, JSON_NUMERIC_CHECK);

echo $test;




Expected result:
----------------
{"test":3434343434343434}
OR
{"test":"3434343434343434"}

Actual result:
--------------
{"test":3434343434340000}

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

Reply via email to