Element proxy

This commit is contained in:
Benoit Blanchon
2022-03-15 11:36:08 +01:00
parent 0cd588c249
commit 8a3b3cfeec
2 changed files with 12 additions and 0 deletions

View File

@@ -204,3 +204,11 @@ TEST_CASE("ElementProxy::operator[]") {
REQUIRE(doc.as<std::string>() == "[null,[null,null,42]]");
}
}
TEST_CASE("ElementProxy::link()") {
StaticJsonDocument<1024> doc1, doc2;
doc1[0].link(doc2);
doc2["hello"] = "world";
CHECK(doc1.as<std::string>() == "[{\"hello\":\"world\"}]");
}

View File

@@ -92,6 +92,10 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >,
return getOrAddUpstreamElement().template to<T>();
}
FORCE_INLINE void link(VariantConstRef value) const {
getOrAddUpstreamElement().link(value);
}
// Replaces the value
//
// bool set(const TValue&)