Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cpp-restsdk] Update json double/float parse. #9577

Merged
merged 2 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generators/tiny-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|Maps|✗|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum||OAS2,OAS3
|Enum||OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
8 changes: 4 additions & 4 deletions samples/client/petstore/cpp-restsdk/client/ModelBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down