JSON parser returns inf for maximum value


In my application I get some JSON as an std::string that is parsed using the juce::JSON::parse() functionality. Inside the JSON to be parsed I have maximum positive and negative double values (1.79769e+308). These values are not parsed to actually be the maximum double value, but rather they become inf and -inf, thus the output JSON is actually invalid (inf and -inf are not valid numbers in JSON).

The place where the maximum double values become inf is in CharacterFunctions::readDoubleValue all the way at the end:

if (decPointIndex != 0)
    r += mulexp10 (result[1], exponent - exponentAdjustment[1]);

At this point a small epsilon will be added to the maximum double value and is then tipped over to inf or -inf.

Is this the desired behavior? I guess for some parsing it makes sense to return inf, but for JSON it is wrong. Is there a workaround for this?


This should be fixed on the develop branch: https://github.com/WeAreROLI/JUCE/commit/7e6a650e8c35e2459abb73949b1198ee5aa15870