Documentation of desired numeric Serialization Behaviour #2672
Unanswered
FelixBenning
asked this question in
Q&A
Replies: 1 comment 3 replies
-
This seems to be a good summary of issues that indeed need some better documentation. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are a ton of issues/bug reports when it comes to serializing numeric values (doubles), which implicitly define desired behaviour.
In an attempt to collect the desired behaviour in one place:
double -> JSON -> double
should incur no loss in precision (cf. Loss of precision when serializing <double> #360 (comment), Loss of precision when serializing <double> #360 (comment))NaN
,Inf
are stored as is inside the C++ JSON structure, but are serialized toNone
(cf. nan number stored as null #388 (comment), Handle infinity and NaN cases #70 (comment)). This does break the first guarantee slightly.String -> JSON -> String
where the String is more precise than double is, that they are rounded to the closest double.json.exception.out_of_range.406
(cf. Doxygen Documentation of the error, Stack Overflow)I think it should be documented somewhere how (De-)serialization of numeric values ought to happen, so that it is clear whether or not a specific behavior is a bug or working as intended.
I guess my Questions are: have I missed anything, is this correct?
Beta Was this translation helpful? Give feedback.
All reactions