|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-10-21 22:56 UTC] digit6 at gmail dot com
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}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
Incorrect ACTUAL output entered in bug, here is the real actual output: {"test":3.43434343434e+15}