我想做我认为在 rapidjson 中非常基本的事情。我想开始一个新对象,然后向该对象添加成员 - 但我很难找出如何正确地做到这一点。我是这样开始的:
rapidjson::Value obj;
obj.SetObject();
rapidjson::Value jName(name, this->rapDoc.GetAllocator());
this->rapCurrent->AddMember((jName).Move(), obj, this->rapDoc.GetAllocator());
接下来我想让 this->rapCurrent 指向新创建的对象成员。我发现完成这项工作的唯一方法是
rapidjson::Value *lastAdded;
rapidjson::Value::ConstMemberIterator it;
for (rapidjson::Value::ConstMemberIterator it = this->rapCurrent->MemberBegin();
it != this->rapCurrent->MemberEnd(); it++) {
lastAdded = (rapidjson::Value *)&it->value;
}
this->rapCurrent = lastAdded;
对于如此简单的任务,这对我来说看起来非常复杂。有人可能知道如何更简单吗?
非常感谢!
蒂莫