rapidjson
rapidjson copied to clipboard
Add support of parsing INFINITY and NAN according to the standard.
Variables of floating point types that have non-normal values, such as INFINITY
and NAN
, cannot be parsed by GenericDocument::Parse(const Ch* str)
even if the flag kParseNanAndInfFlag
is set, and that's due to the fact that the parser tests these exceptional values against NaN
, Infinity
, -Infinity
, Inf
and -Inf
. However, according to the standard, when converting floating point types to string, e.g. using std::to_string(double)
, these exceptional values get converted as nan
, inf
or -inf
! This pull request fixes this issue (#2099).
Please update the existing unit test as well.
Oops, I missed that! Done.
Hi @miloyip, We would like to adopt these changes next week from our side. However, since I'm not comprehensively familiar with the implementation of this library as a whole, your feedback would be appreciated on whether these changes are adequate to take or otherwise what kind of unwanted side effects they may cause. We're using the library primarily for C++, and as it stands, we have the issue submitted in #2099. Thanks!
We faced this issue and see rapidjson crashing for doc.ParseInsitu<kParseNanAndInfFlag | kParseInsituFlag | kParseFullPrecisionFlag>. Can this fix be merged?