forked from loafle/openapi-generator-original
[cpp-restsdk] Update json double/float parse. (#9577)
* [cpp-restsdk] Update json double/float parse. Fix cpp-restsdk double and float parse. double.NaN was parsed when server doesn't ensure the floating point value has decimal point in in. * Update docs & samples.
This commit is contained in:
parent
670c5884b6
commit
73b34ade6a
@ -249,13 +249,13 @@ bool ModelBase::fromJson( const web::json::value& val, bool & outVal )
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, float & outVal )
|
||||
{
|
||||
outVal = !val.is_double() ? std::numeric_limits<float>::quiet_NaN(): static_cast<float>(val.as_double());
|
||||
return val.is_double();
|
||||
outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits<float>::quiet_NaN(): static_cast<float>(val.as_double());
|
||||
return val.is_double() || val.is_integer();
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, double & outVal )
|
||||
{
|
||||
outVal = !val.is_double() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
||||
return val.is_double() ;
|
||||
outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
||||
return val.is_double() || val.is_integer();
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, int32_t & outVal )
|
||||
{
|
||||
|
@ -260,13 +260,13 @@ bool ModelBase::fromJson( const web::json::value& val, bool & outVal )
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, float & outVal )
|
||||
{
|
||||
outVal = !val.is_double() ? std::numeric_limits<float>::quiet_NaN(): static_cast<float>(val.as_double());
|
||||
return val.is_double();
|
||||
outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits<float>::quiet_NaN(): static_cast<float>(val.as_double());
|
||||
return val.is_double() || val.is_integer();
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, double & outVal )
|
||||
{
|
||||
outVal = !val.is_double() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
||||
return val.is_double() ;
|
||||
outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
||||
return val.is_double() || val.is_integer();
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, int32_t & outVal )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user