fixed #70
This commit is contained in:
parent
1580eee4ed
commit
17609f244d
4 changed files with 55 additions and 5 deletions
18
src/json.hpp
18
src/json.hpp
|
@ -431,7 +431,14 @@ class basic_json
|
|||
/// create a floating-point number (explicit)
|
||||
inline basic_json(const number_float_t& value)
|
||||
: m_type(value_t::number_float), m_value(value)
|
||||
{}
|
||||
{
|
||||
// replace infinity and NAN by null
|
||||
if (not std::isfinite(value))
|
||||
{
|
||||
m_type = value_t::null;
|
||||
m_value = json_value();
|
||||
}
|
||||
}
|
||||
|
||||
/// create a floating-point number (implicit)
|
||||
template<typename T, typename = typename
|
||||
|
@ -441,7 +448,14 @@ class basic_json
|
|||
>
|
||||
inline basic_json(const T value) noexcept
|
||||
: m_type(value_t::number_float), m_value(number_float_t(value))
|
||||
{}
|
||||
{
|
||||
// replace infinity and NAN by null
|
||||
if (not std::isfinite(value))
|
||||
{
|
||||
m_type = value_t::null;
|
||||
m_value = json_value();
|
||||
}
|
||||
}
|
||||
|
||||
/// create a container (array or object) from an initializer list
|
||||
inline basic_json(list_init_t init, bool type_deduction = true,
|
||||
|
|
|
@ -431,7 +431,14 @@ class basic_json
|
|||
/// create a floating-point number (explicit)
|
||||
inline basic_json(const number_float_t& value)
|
||||
: m_type(value_t::number_float), m_value(value)
|
||||
{}
|
||||
{
|
||||
// replace infinity and NAN by null
|
||||
if (not std::isfinite(value))
|
||||
{
|
||||
m_type = value_t::null;
|
||||
m_value = json_value();
|
||||
}
|
||||
}
|
||||
|
||||
/// create a floating-point number (implicit)
|
||||
template<typename T, typename = typename
|
||||
|
@ -441,7 +448,14 @@ class basic_json
|
|||
>
|
||||
inline basic_json(const T value) noexcept
|
||||
: m_type(value_t::number_float), m_value(number_float_t(value))
|
||||
{}
|
||||
{
|
||||
// replace infinity and NAN by null
|
||||
if (not std::isfinite(value))
|
||||
{
|
||||
m_type = value_t::null;
|
||||
m_value = json_value();
|
||||
}
|
||||
}
|
||||
|
||||
/// create a container (array or object) from an initializer list
|
||||
inline basic_json(list_init_t init, bool type_deduction = true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue