3 ms·
Every number in JavaScript is, JSON does not specify.
by justincormack 7y ago
Every number in JavaScript is, JSON does not specify.
- jacobolus 7y ago“JavaScript Object” is right there in the name.
- overgard 7y agoJava is also in the name JavaScript, but we know how much that has to do with it.
- TheRealPomax 7y agoindeed, we've all read that history. And we all know how much JavasSript has to do with "JavaScript Object Notation", too right? Basically everything?
- overgard 7y agoOther than shared syntax, JSON is its own thing.
- jacobolus 7y agoUpdate: The IETF version is a bit more explicit. https://tools.ietf.org/html/rfc8259#section-6 https://tools.ietf.org/html/rfc8259#section-6 > This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754 binary64 (double precision) numbers [IEEE754] is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision. A JSON number such as 1E400 or 3.141592653589793238462643383279 may indicate potential interoperability problems, since it suggests that the software that created it expects receiving software to have greater capabilities for numeric magnitude and precision than is widely available. > Note that when such software is used, numbers that are integers and are in the range [-(2^53)+1, (2^53)-1] are interoperable in the sense that implementations will agree exactly on their numeric values. Or to paraphrase: if you pretend that every JSON number is a JavaScript number (double-precision float), you will generally be fine. If you don’t, you are responsible for the inevitable interpoperability problems you’ll have with most current JSON parsers.