I'm having a pretty basic (and well-know) floating precision problem with the JSON part of cpprestsdk. I read in a number with a decimal point (e..g. 13.12) and want to generate a JSON number for that. But if I write:
myValue["number"] = json::value::number(13.12);
due to typical numerical precision problems, I get:
Of course, I can internally represent the decimal in such a way that there will be no rounding.
But in order to get the number into a JSON structure, I have to use json::value::number(), only accepts double as input (and a bunch of integer types, of course) ,and when using double, I always get the long number, which the REST service on the other end rejects.
Is there any way to get the correct decimal into the JSON structure?