fix: null values not resulting in parsed optional nullopt for json

This commit is contained in:
Jan 2024-08-08 19:21:09 +02:00
parent 219590898f
commit ae6984dff9
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C

View File

@ -18,7 +18,7 @@ namespace nlohmann
template<class T> void optional_from_json(const nlohmann::json& j, const char* name, std::optional<T>& value)
{
const auto it = j.find(name);
if (it != j.end())
if (it != j.end() && !it->is_null())
value = it->get<T>();
else
value = std::nullopt;