diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index bfcf89a40f..709bc5fd50 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -34,7 +34,7 @@ template , template ordered_map(It first, It last, const Allocator& alloc = Allocator()) : Container{first, last, alloc} {} - ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) + ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) : Container{init, alloc} {} std::pair emplace(const key_type& key, T&& t) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e40e3b05bd..ec33a847ad 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -17070,7 +17070,7 @@ template , template ordered_map(It first, It last, const Allocator& alloc = Allocator()) : Container{first, last, alloc} {} - ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) + ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) : Container{init, alloc} {} std::pair emplace(const key_type& key, T&& t) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 52db3589cf..6249db63e4 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -835,6 +835,18 @@ TEST_CASE("regression tests 2") CHECK(j.dump() == "[1,4]"); } + + SECTION("issue #3343 - json and ordered_json are not interchangable") + { + json::object_t jobj({ { "product", "one" } }); + ordered_json::object_t ojobj({{"product", "one"}}); + + auto jit = jobj.begin(); + auto ojit = ojobj.begin(); + + CHECK(jit->first == ojit->first); + CHECK(jit->second.get() == ojit->second.get()); + } } DOCTEST_CLANG_SUPPRESS_WARNING_POP