Boost logo

Boost :

From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2020-09-25 14:17:24


>> I am wondering. If I have a small web service for generating prime numbers,
>> and I need to return them in a JSON file, is my only option to pass it as
>> string?
>> Prime numbers of this kind are bigger than uint64_t. But they are not as
>> big as 1MB. Is such a use case for a number so unusual that it cannot be
>> stored as a JSON number?
>> Are JSON numbers only good for storing int-based identifiers?
> I don't know what an int-based identifier is, but I do know that the
> use cases for machine-representable ints (that is, and int that is the
> size of an int, fits in a register, etc.) is >99% and the use cases
> for a web service that generates prime numbers is <1%. That's what
> should drive the design.

To add to that: JSON is essentially JavaScript based. JavaScript had
long time no ints, only doubles. And the new BigInt can't be converted
to JSON

So to answer the question: Yes your only option is to pass it as string.
Otherwise it is foremost non-portable.




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk