This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/json_util.hpp

17 lines
322 B
C++
Raw Normal View History

#pragma once
namespace big
{
template<typename ValueType>
static inline void set_from_key_or_default(const nlohmann::json& j, const char* key, ValueType& value, ValueType default_value = {})
{
if (j.contains(key) && !j[key].is_null())
{
j.at(key).get_to(value);
}
else
{
value = default_value;
}
}
}