diff --git a/extras/tests/JsonDocument/ElementProxy.cpp b/extras/tests/JsonDocument/ElementProxy.cpp index 1912d5f9..8e13180e 100644 --- a/extras/tests/JsonDocument/ElementProxy.cpp +++ b/extras/tests/JsonDocument/ElementProxy.cpp @@ -204,3 +204,11 @@ TEST_CASE("ElementProxy::operator[]") { REQUIRE(doc.as() == "[null,[null,null,42]]"); } } + +TEST_CASE("ElementProxy::link()") { + StaticJsonDocument<1024> doc1, doc2; + doc1[0].link(doc2); + doc2["hello"] = "world"; + + CHECK(doc1.as() == "[{\"hello\":\"world\"}]"); +} diff --git a/src/ArduinoJson/Array/ElementProxy.hpp b/src/ArduinoJson/Array/ElementProxy.hpp index d54de494..77f241a7 100644 --- a/src/ArduinoJson/Array/ElementProxy.hpp +++ b/src/ArduinoJson/Array/ElementProxy.hpp @@ -92,6 +92,10 @@ class ElementProxy : public VariantOperators >, return getOrAddUpstreamElement().template to(); } + FORCE_INLINE void link(VariantConstRef value) const { + getOrAddUpstreamElement().link(value); + } + // Replaces the value // // bool set(const TValue&)