MemberProxy.link()

This commit is contained in:
Benoit Blanchon
2022-03-14 19:44:57 +01:00
parent b02d979ceb
commit 0cd588c249
2 changed files with 12 additions and 0 deletions

View File

@@ -277,3 +277,11 @@ TEST_CASE("MemberProxy::createNestedObject(key)") {
CHECK(doc["status"]["weather"]["temp"] == 42);
}
TEST_CASE("MemberProxy::link()") {
StaticJsonDocument<1024> doc1, doc2;
doc1["obj"].link(doc2);
doc2["hello"] = "world";
CHECK(doc1.as<std::string>() == "{\"obj\":{\"hello\":\"world\"}}");
}

View File

@@ -113,6 +113,10 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >,
getUpstreamMember().remove(key);
}
FORCE_INLINE void link(VariantConstRef value) {
getOrAddUpstreamMember().link(value);
}
template <typename TValue>
FORCE_INLINE typename VariantTo<TValue>::type to() {
return getOrAddUpstreamMember().template to<TValue>();