Hacker News new | ask | show | jobs
by neunhoef 3210 days ago
Many JSON parsers will treat long numbers as doubles. Therefore the only safe way to store them without potential loss is in a string. Without the encoding in the article or something along these lines, the sorting done by a database is not compatible with the integer sorting.
1 comments

It remans a fact that the JSON spec does not limit the length of numbers, so there is no need for this kind of kludge.

If Arango would just allow unlimited numbers in JSON data and sort them numerically, developers could use a different JSON encoder and parser in their language of choice, that would encode and parse numbers from the unlimited representation allowed by JSON to whatever bignum library their language has.

There is a need for this kind of kludge because systems that you interact with will lose precision with large numbers. If Arango was the only system parsing the json data that would be one thing, but that is not a real-world use-case.