You need to make use of JSON_BIGINT_AS_STRING
$yourresultsarray = json_decode($json, true, 64, JSON_BIGINT_AS_STRING);
or you could simply set the precision
parameter on PHP.ini.
<?php
ini_set('precision',20); //<--- Add this on top as shown
Вопрос
I am working on an app that will have to send 64bit numbers back and forth with a php api via JSON which will store and retrieve them from a MySQL database. How do you format them in JSON so as not to lose any precision? Should I send them as raw integers? Strings? Hex? I'm not sure what the best way is to handle this
Решение
You need to make use of JSON_BIGINT_AS_STRING
$yourresultsarray = json_decode($json, true, 64, JSON_BIGINT_AS_STRING);
or you could simply set the precision
parameter on PHP.ini.
<?php
ini_set('precision',20); //<--- Add this on top as shown