I have the typical problem with big int decoded with json_decode and try using the JSON_BIGINT_AS_STRING option, but it seems that php ignores the parameter.
I tried the php.net example code:
$json = '12345678901234567890';
var_dump(json_decode($json));
var_dump(json_decode($json, false, 512, JSON_BIGINT_AS_STRING));
The output should be:
float(1.2345678901235E+19)
string(20) "12345678901234567890"
But in my server (xampp php 5.4.7) I have:
float(1.2345678901235E+19)
float(1.2345678901235E+19)
Thanks for the help!
EDIT:
I had to confirm this, but this behavior has been classified as a bug in PHP. Please see the bug report for more details.
The existing behavior causes your string to be cast as int/float (number type) internally by PHP. If you provide a JSON encoded object, array, or string the function does what it describes, but for now this reflects the buggy behavior.
As you can see both give us a float, but when we use a valid JSON object, array, or valid JSON as a string we get the expected result.
The output looks like the following…
This should be fixed soon, but for now I just wanted to update my answer to reflect this new information.