File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/framework/global/serialization Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -602,22 +602,38 @@ bool JsonObject::isValid() const
602602
603603bool JsonObject::empty () const
604604{
605+ if (!isValid ()) {
606+ return true ;
607+ }
608+
605609 return object_const (m_data).size () == 0 ;
606610}
607611
608612size_t JsonObject::size () const
609613{
614+ if (!isValid ()) {
615+ return 0 ;
616+ }
617+
610618 return object_const (m_data).size ();
611619}
612620
613621bool JsonObject::contains (const std::string& key) const
614622{
623+ if (!isValid ()) {
624+ return false ;
625+ }
626+
615627 const picojson::object& o = object_const (m_data);
616628 return o.find (key) != o.cend ();
617629}
618630
619631JsonValue JsonObject::value (const std::string& key, JsonValue def) const
620632{
633+ if (!isValid ()) {
634+ return def;
635+ }
636+
621637 const picojson::object& o = object_const (m_data);
622638 auto it = o.find (key);
623639 if (it != o.cend ()) {
You can’t perform that action at this time.
0 commit comments