Hello, I'm trying to use this as part of a specialized json parsing/printing library. It is essential that performing a round trip parse-print does not modify data. Therefore, internally, we store decimals as strings, guaranteeing that formatting is not destroyed. Is it possible to reproduce this in nlohmann/json? or is it inherently destructive?
Examples:
2.500 becomes 2.5
1E-22 becomes 1e-22
66.899999999999991 becomes 66.89999999999999
I understand the limitations of float representation - the hope is that it's possible to enable a mode/custom parsing that internally parses decimals into as strings, so as to side-step these limitations.
Most broadly, the question is if it's possible to get to a guarantee that (other than insignificant white-space)
json::parse(my_json_string).dumps() == my_json_string
Thanks,
Nick
Hello, I'm trying to use this as part of a specialized json parsing/printing library. It is essential that performing a round trip parse-print does not modify data. Therefore, internally, we store decimals as strings, guaranteeing that formatting is not destroyed. Is it possible to reproduce this in nlohmann/json? or is it inherently destructive?
Examples:
2.500becomes2.51E-22becomes1e-2266.899999999999991becomes66.89999999999999I understand the limitations of float representation - the hope is that it's possible to enable a mode/custom parsing that internally parses decimals into as strings, so as to side-step these limitations.
Most broadly, the question is if it's possible to get to a guarantee that (other than insignificant white-space)
json::parse(my_json_string).dumps() == my_json_stringThanks,
Nick