diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 8ed0a3965..386fd0ea2 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -399,7 +399,7 @@ class input_adapter /// input adapter for array template input_adapter(T (&array)[N]) - : input_adapter(std::begin(array), std::end(array)) {} + : input_adapter(std::begin(array), array[N - 1] == 0 ? std::prev(std::end(array)) : std::end(array)) {} /// input adapter for contiguous container template::eof(): return token_type::end_of_input; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ee72531b7..15c49302d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2554,7 +2554,7 @@ class input_adapter /// input adapter for array template input_adapter(T (&array)[N]) - : input_adapter(std::begin(array), std::end(array)) {} + : input_adapter(std::begin(array), array[N - 1] == 0 ? std::prev(std::end(array)) : std::end(array)) {} /// input adapter for contiguous container template::eof(): return token_type::end_of_input; diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index f930c9745..99b9f5c29 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -688,7 +688,7 @@ TEST_CASE("nst's JSONTestSuite") "test/data/nst_json_testsuite/test_parsing/n_number_real_with_invalid_utf8_after_e.json", "test/data/nst_json_testsuite/test_parsing/n_number_real_without_fractional_part.json", "test/data/nst_json_testsuite/test_parsing/n_number_starting_with_dot.json", - //"test/data/nst_json_testsuite/test_parsing/n_number_then_00.json", + "test/data/nst_json_testsuite/test_parsing/n_number_then_00.json", "test/data/nst_json_testsuite/test_parsing/n_number_with_alpha.json", "test/data/nst_json_testsuite/test_parsing/n_number_with_alpha_char.json", "test/data/nst_json_testsuite/test_parsing/n_number_with_leading_zero.json", @@ -1067,7 +1067,7 @@ TEST_CASE("nst's JSONTestSuite (2)") "test/data/nst_json_testsuite2/test_parsing/n_incomplete_false.json", "test/data/nst_json_testsuite2/test_parsing/n_incomplete_null.json", "test/data/nst_json_testsuite2/test_parsing/n_incomplete_true.json", - //"test/data/nst_json_testsuite2/test_parsing/n_multidigit_number_then_00.json", + "test/data/nst_json_testsuite2/test_parsing/n_multidigit_number_then_00.json", "test/data/nst_json_testsuite2/test_parsing/n_number_++.json", "test/data/nst_json_testsuite2/test_parsing/n_number_+1.json", "test/data/nst_json_testsuite2/test_parsing/n_number_+Inf.json",