Util: Add more ways of accessing and creating Json::Value objects

This commit is contained in:
Riyyi
2022-06-23 13:47:07 +02:00
parent 9f7fe81ef6
commit 8bfae9b483
4 changed files with 96 additions and 7 deletions
+12
View File
@@ -30,6 +30,18 @@ public:
m_members.emplace(key, std::move(value));
}
Value& at(const std::string& key)
{
if (m_members.find(key) == m_members.end()) {
emplace(key, {});
}
return m_members.at(key);
}
Value& operator[](const std::string& key) { return at(key); }
const Value& at(const std::string& key) const { return m_members.at(key); }
const Value& operator[](const std::string& key) const { return m_members.at(key); }
const std::map<std::string, Value>& members() const { return m_members; }
private: