The following code produces a core dump with this error message: Assertion `m_value.object->find(key) != m_value.object->end()' failed
int main() {
nlohmann::json j;
j["subobject"] = {{"key1", "value1"}, {"key2", "value2"}};
const nlohmann::json &subobject = j["subobject"];
if (!subobject["key1"].is_null()) {
std::cout << "CHECK" << std::endl;
} else {
std::cout << "FAIL" << std::endl;
}
if (!subobject["key3"].is_null()) {
std::cout << "CHECK" << std::endl;
} else {
std::cout << "FAIL" << std::endl;
}
return 0;
}
This is because the check inserts {"key3", null} into the object.
I'm not sure whether this behaviour is intentionally, it might at least become a pitfall for some, so I wanted to bring this to your attention.
The following code produces a core dump with this error message:
Assertion `m_value.object->find(key) != m_value.object->end()' failedThis is because the check inserts
{"key3", null}into the object.I'm not sure whether this behaviour is intentionally, it might at least become a pitfall for some, so I wanted to bring this to your attention.