Javascript presents all numbers as doubles with double precision. This means that it loses accuracy when working with numbers on the highest end of the 64-bit Java Long datatype - anything after 17 digits. For example, the number:
714341252076979033
... becomes:
714341252076979100
My database uses long identifiers, and some of them are in the danger zone. I could change the offensive values ββin the database, but that would be difficult in my application. Instead, right now, I pretty quickly guarantee that the server encodes long identifiers as strings in all ajax responses.
However, I would prefer to deal with this in Javascript. My question is: is there a best practice for forcing JSON parsing to process a number as a string?
source share