Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Actually JSON doesn't specify what numbers are - it would be perfectly licit for a JSON parser to transparently use a real numerical tower, allowing perfect representations of any non-repeating decimal fractional number (since it has to be represented as a dotted-fraction and there's no support for a vinculum (aka U+0305 / COMBINING OVERLINE / ◌̅ / 3.21̅) there's no way to represent non-repeating fractions if there is not a non-repeating representation in base 10). A few JSON parsers even do this. That said, if you don't control the both sides sending something that won't be handled by the lowest-common-denominator (browser JSON parsers / JS numbers) is asking for trouble.


The short story is that if you want real foolproof interoperability, always represent numbers as strings in JSON.


Interestingly, your example renders incorrectly for me (Firefox/W10). The overline is placed between 1 and ).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: