I realize that PHP does not support unsigned integers, but I'm wondering how to solve this issue I'm having with json_decode(). When I decode JSON that contains unsigned ints above 2^31, they come out negative, since they are being treated as signed ints. Is this something I can rectify by configuring my php.ini file or is 开发者_如何转开发there just something about json_decode that I'm not getting?
The development version of PHP seems to have a planned option to json_decode()
exactly for this problem: JSON_BIGINT_AS_STRING
(see Example #5 in the manual) but there seems to be no production fix for this right now.
See also this comment in the user contributed notes.
Any chance of outputting strings on the encoding end somehow?
You can use the PHP BC Math extension!
For arbitrary precision mathematics PHP offers the Binary Calculator which supports numbers of any size and precision, represented as strings.
精彩评论