Commit 737d4372 by Niels

Merge branch 'feature/issue329' into develop

parents a29fcae4 d9106722
...@@ -517,7 +517,7 @@ To compile and run the tests, you need to execute ...@@ -517,7 +517,7 @@ To compile and run the tests, you need to execute
$ make check $ make check
=============================================================================== ===============================================================================
All tests passed (8905168 assertions in 35 test cases) All tests passed (8905169 assertions in 35 test cases)
``` ```
Alternatively, you can use [CMake](https://cmake.org) and run Alternatively, you can use [CMake](https://cmake.org) and run
......
...@@ -8960,6 +8960,13 @@ basic_json_parser_63: ...@@ -8960,6 +8960,13 @@ basic_json_parser_63:
{ {
// parse with strtod // parse with strtod
result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), NULL); result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), NULL);
// replace infinity and NAN by null
if (not std::isfinite(result.m_value.number_float))
{
type = value_t::null;
result.m_value = basic_json::json_value();
}
} }
// save the type // save the type
......
...@@ -8257,6 +8257,13 @@ class basic_json ...@@ -8257,6 +8257,13 @@ class basic_json
{ {
// parse with strtod // parse with strtod
result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), NULL); result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), NULL);
// replace infinity and NAN by null
if (not std::isfinite(result.m_value.number_float))
{
type = value_t::null;
result.m_value = basic_json::json_value();
}
} }
// save the type // save the type
......
...@@ -489,4 +489,10 @@ TEST_CASE("regression tests") ...@@ -489,4 +489,10 @@ TEST_CASE("regression tests")
j["/this/that/2"_json_pointer] = 27; j["/this/that/2"_json_pointer] = 27;
CHECK(j == json({{"this", {{"that", {nullptr, nullptr, 27}}}}})); CHECK(j == json({{"this", {{"that", {nullptr, nullptr, 27}}}}}));
} }
SECTION("issue #329 - serialized value not always can be parsed")
{
json j = json::parse("22e2222");
CHECK(j == json());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment