🐛 fix a bug due to missing overloads in ordered_map container

This commit is contained in:
Niels Lohmann
2020-07-28 14:20:31 +02:00
parent 1b8efed06f
commit e590604822
5 changed files with 213 additions and 6 deletions

View File

@@ -1976,6 +1976,25 @@ TEST_CASE("regression tests")
json result = json::from_cbor(data, true, false);
CHECK(result.is_discarded());
}
SECTION("issue #2315 - json.update and vector<pair>does not work with ordered_json")
{
nlohmann::ordered_json jsonAnimals = {{"animal", "dog"}};
nlohmann::ordered_json jsonCat = {{"animal", "cat"}};
jsonAnimals.update(jsonCat);
CHECK(jsonAnimals["animal"] == "cat");
std::vector<std::pair<std::string, int64_t>> intData = {std::make_pair("aaaa", 11),
std::make_pair("bbb", 222)
};
nlohmann::ordered_json jsonObj;
for (const auto& data : intData)
{
jsonObj[data.first] = data.second;
}
CHECK(jsonObj["aaaa"] == 11);
CHECK(jsonObj["bbb"] == 222);
}
}
#if !defined(JSON_NOEXCEPTION)