From: warren at guy dot net dot au
Operating system: FreeBSD 6.3
PHP version: 5.2.11
PHP Bug Type: JSON related
Bug description: json_decode integer truncation on 32-bit machines
Description:
------------
json_decode truncates numbers greater than 32 bit int 2147483647 on 32 bit
system
Reproduce code:
---------------
<?
$json_encoded =
'{"test_id_small_int":12345,"test_id_maxint":2147483647,"test_id_maxint_plus_two":2147483649,"test_id_huge_int":80000000000}';
var_dump(json_decode($json_encoded));
?>
Expected result:
----------------
object(stdClass)#1 (4) {
["test_id_small_int"]=>
int(12345)
["test_id_maxint"]=>
int(2147483647)
["test_id_maxint_plus_two"]=>
float(2147483649)
["test_id_huge_int"]=>
float(80000000000)
}
or even strings instead of floats would work for me.
Actual result:
--------------
object(stdClass)#1 (4) {
["test_id_small_int"]=>
int(12345)
["test_id_maxint"]=>
int(2147483647)
["test_id_maxint_plus_two"]=>
int(2147483647)
["test_id_huge_int"]=>
int(2147483647)
}
--
Edit bug report at http://bugs.php.net/?id=49991&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49991&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49991&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49991&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49991&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49991&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49991&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49991&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49991&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49991&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49991&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49991&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49991&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49991&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49991&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49991&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49991&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49991&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49991&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49991&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49991&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49991&r=mysqlcfg