Description
-
Describe what you want to achieve.
I have a config struct that gets initialized via a json file. I want to make sure that any floats in the json file will round trip (convert from string-float-string) and remain identical. To enforce this, I need a way of seeing if the provided JSON-float (which is represented on the computer as a string) exceeds a certain number of digits of precision (in the case of string-float-string roundtrips, this precision is 15 decimal digits on my machine). Once I have a way to read the JSON-float as a string before it gets converted to a C++-float, I can throw a runtime error if the user tries to provide a JSON-float of too high a precision. -
Describe what you tried.
I can control JSON serialization viastd::setprecision()
, but I cannot control JSON deserialization. I know that there is a SAX interface that looks like I might be able to get an event hook on when the JSON-float gets parsed into a string before conversion to a C++-float, but I don't know how to use it as the SAX documentation said that it doesn't handle the actual serialization and deserialization (I also don't know what SAX is). -
Describe which system (OS, compiler) you are using.
MacOS, Gcc-8 -
Describe which version of the library you are using (release version, develop branch).
master, v3.7.3
P.S: Very new to C++, your library is making me hate the language a little less :)