diff --git a/src/ArduinoJson/Collection/CollectionData.hpp b/src/ArduinoJson/Collection/CollectionData.hpp index dd08bb77..354d38dc 100644 --- a/src/ArduinoJson/Collection/CollectionData.hpp +++ b/src/ArduinoJson/Collection/CollectionData.hpp @@ -58,5 +58,7 @@ bool arrayEquals(const detail::CollectionData* lhs, const detail::CollectionData* rhs); bool objectEquals(const detail::CollectionData& lhs, const detail::CollectionData& rhs); +bool objectEquals(const detail::CollectionData* lhs, + const detail::CollectionData* rhs); ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/src/ArduinoJson/Collection/CollectionImpl.hpp b/src/ArduinoJson/Collection/CollectionImpl.hpp index 20f2f759..45433568 100644 --- a/src/ArduinoJson/Collection/CollectionImpl.hpp +++ b/src/ArduinoJson/Collection/CollectionImpl.hpp @@ -138,4 +138,14 @@ inline bool objectEquals(const CollectionData& lhs, const CollectionData& rhs) { return count == rhs.size(); } +inline bool objectEquals(const CollectionData* lhs, const CollectionData* rhs) { + if (lhs == rhs) + return true; + + if (!lhs || !rhs) + return false; + + return objectEquals(*lhs, *rhs); +} + ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/src/ArduinoJson/Object/JsonObject.hpp b/src/ArduinoJson/Object/JsonObject.hpp index 345819e2..7b528f83 100644 --- a/src/ArduinoJson/Object/JsonObject.hpp +++ b/src/ArduinoJson/Object/JsonObject.hpp @@ -100,7 +100,7 @@ class JsonObject : public detail::VariantOperators { // Compares the content of two objects. FORCE_INLINE bool operator==(JsonObject rhs) const { - return JsonObjectConst(data_) == JsonObjectConst(rhs.data_); + return objectEquals(data_, rhs.data_); } // Gets or sets the member with specified key. diff --git a/src/ArduinoJson/Object/JsonObjectConst.hpp b/src/ArduinoJson/Object/JsonObjectConst.hpp index 1b0ae09d..8759b935 100644 --- a/src/ArduinoJson/Object/JsonObjectConst.hpp +++ b/src/ArduinoJson/Object/JsonObjectConst.hpp @@ -108,13 +108,7 @@ class JsonObjectConst : public detail::VariantOperators { // Compares objects. FORCE_INLINE bool operator==(JsonObjectConst rhs) const { - if (data_ == rhs.data_) - return true; - - if (!data_ || !rhs.data_) - return false; - - return objectEquals(*data_, *rhs.data_); + return objectEquals(data_, rhs.data_); } private: