Я смог понять это;однако, поскольку я не нашел документации, подтверждающей это, я не уверен, действительно ли я полагаюсь на какое-либо неопределенное или неподдерживаемое поведение.
//Prepare 'root' object as a document
rapidjson::Document document;
rapidjson::Document::AllocatorType& allocator = document.GetAllocator();
document.SetObject();
// 'document' currently serializes to {}
//Create an empty rapidjson 'object' as a Value, and add it to root
rapidjson::Value nestedObject(rapidjson::kObjectType);
document.AddMember("Parent", nestedObject, allocator);
// 'document' currently serializes to {"Parent":{}}
/*Retrieve the 'object' as a Value
This step is important! Trying to reuse the same 'nestedObject' Value from before
without "re-retrieving" it will result in assertion errors at runtime.
If you try to "re-retrieve" into the existing 'nestedValue' instance, the end
result below will be {"Parent":null}*/
rapidjson::Value &nestedObjectValue = document["Parent"];
//Modify the 'nestedObjectValue'
nestedObjectValue.AddMember("child", "child_value", allocator);
// 'document' currently serializes to {"Parent":{"child":"child_value"}}
В конечном счете, это было желаемое поведение, которое я хотел.У меня есть доступ к вложенному объекту, и я могу изменить его по своему желанию, и изменения повлияют на корневой документ.