Big integers should be returned as string (~JSON_BIGINT_AS_STRING)
I think that it is better to return large integers as string instead of casting them to float.
What do you think? Any tips, how to efficiently decide whether string contains integer larger than MAX_INT?
Any tips, how to efficiently decide whether string contains integer larger than MAX_INT?
Some cute regexp?
This is what I have now – https://github.com/JanTvrdik/neon/commit/c302826d18bc3c3d2fb731cf908aca10498fce86
What to do with numbers such as 0x123456789123456781345678913? I would prefer to return them as decimal string however I'm not aware of any efficient solution to perform the conversion.
What about E_USER_WARNING on big number? To force user enclose it in quotes as a string. JSON has the JSON_BIGINT_AS_STRING only for interoperability between 32-bit and 64-bit systems.
What to do with numbers such as 0x123456789123456781345678913? I would prefer to return them as decimal string however I'm not aware of any efficient solution to perform the conversion.
The only sane way I know in PHP is the GMP extension.
What about E_USER_WARNING on big number? To force user enclose it in quotes as a string.
Please, don't. JSON NEON is not something you always manually construct in the application, it's rather given from elsewhere, really not something you control directly (thus should not trigger an error).
Please, don't. JSON is not something you manually construct
- We're talking about NEON here 2) JSON RFC allows a JSON parser to restrict the range of numbers it can handle
But still agreed, warning is the solution I would like to avoid.
There is no sane way how to handle big numbers or have you forgotten about very large decimals?
It should be string representation of given number or native PHP representation if possible. This is the simple solution
We can add custom number parser into mix as a fallback or parameter with default set to sane parser. Quite easy, hard problem of what to do with numbers will be solved by user.
In my magic ball I see this heading to custom number parser with default implementation that handles numbers of all colours and sizes.