Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/framework/global/serialization/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,22 +602,38 @@ bool JsonObject::isValid() const

bool JsonObject::empty() const
{
if (!isValid()) {
return true;
}

return object_const(m_data).size() == 0;
}

size_t JsonObject::size() const
{
if (!isValid()) {
return 0;
}

return object_const(m_data).size();
}

bool JsonObject::contains(const std::string& key) const
{
if (!isValid()) {
return false;
}

const picojson::object& o = object_const(m_data);
return o.find(key) != o.cend();
}

JsonValue JsonObject::value(const std::string& key, JsonValue def) const
{
if (!isValid()) {
return def;
}

const picojson::object& o = object_const(m_data);
auto it = o.find(key);
if (it != o.cend()) {
Expand Down
Loading