added nlohmann::json operator+

Add a simple plus operator to easily combine json objects
This commit is contained in:
김형준 2022-08-05 11:39:33 +09:00 committed by GitHub
parent 01af734d63
commit efc1b9df62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5074,6 +5074,22 @@ std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j)
return j.dump();
}
inline nlohmann::json operator+(const nlohmann::json& lhs, const nlohmann::json& rhs)
{
nlohmann::json ret;
for (const auto& el : lhs.items())
{
ret[el.key()] = el.value();
}
for (const auto& el : rhs.items())
{
ret[el.key()] = el.value();
}
return ret;
}
inline namespace literals
{
inline namespace json_literals