diff --git a/CHANGELOG.md b/CHANGELOG.md index 0839d765..06661a37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,3 +15,4 @@ HEAD * Reference-count shared strings * Always store `serialized("string")` by copy (#1915) * Remove the zero-copy mode of `deserializeJson()` and `deserializeMsgPack()` +* Fix double lookup in `to()` diff --git a/src/ArduinoJson/Variant/JsonVariant.hpp b/src/ArduinoJson/Variant/JsonVariant.hpp index 1d504d74..ed6635a0 100644 --- a/src/ArduinoJson/Variant/JsonVariant.hpp +++ b/src/ArduinoJson/Variant/JsonVariant.hpp @@ -105,8 +105,10 @@ template template typename enable_if::value, JsonVariant>::type VariantRefBase::to() const { - detail::VariantData::setNull(getOrCreateData(), getResourceManager()); - return *this; + auto data = getOrCreateData(); + auto resources = getResourceManager(); + detail::VariantData::setNull(data, resources); + return JsonVariant(data, resources); } template