JSON Integer Parsing¶
JSON integer parsing in Glaze rejects negative exponents and decimal values.
Valid examples for a uint8_t:
Invalid examples for a uint8_t:
This applies for larger integer types as well, such as int64_t.
Glaze rejects negative exponents and decimal values for the following reasons:
- Fractional values cannot be stored exactly in integers, so data loss can be unknown to the developer.
- Fractional values should be rounded in different ways or truncated when converted to integers based on the application. It is better to parse these values as floating point values and then apply specific conversions.
- The parser runs faster
- We are able to disambiguate between values that can be stored in integer types and floating point types, which allows auto variant deduction for variants containing both integers and floating point values.