Reputation: 1516
When I JSON decoded the JSON in my php one of the numeric value is altered. My JSON is given below:
[
{
"__m":"m_0_7p"
},
100001572061234,
null,
"profile_friends",
"pb_friends_tl",
"\/ajax\/add_friend\/action.php",
"",
true,
null,
false,
null,
null,
"friends_tab",
[]
]
On Json decode the output for the above json is
Array ( [0] => stdClass Object ( [__m] => m_0_7o ) [1] => 1.000091378372E+14 [2] => [3] => profile_friends [4] => pb_friends_tl [5] => /ajax/add_friend/action.php [6] => [7] => 1 [8] => [9] => [10] => [11] => [12] => friends_tab [13] => Array ( ) )
where '100001572061234' changed into 1.000091378372E+14. Don't know why this is happening.
Upvotes: 1
Views: 596
Reputation: 212522
When PHP displays numbers, it uses the php.ini precision setting to decide whether it should display all digits, or use scientific format..... this is a display setting, it doesn't change the value internally.
However, that value is too large for a signed integer in 32-bit PHP, so it will be treated as a float in PHP
From PHP 5.4.0 you have an option to use the option flags to determine how large integer values are to be handled
$decoded = json_decode($encoded, false, null, JSON_BIGINT_AS_STRING);
Upvotes: 2