문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top