rapidjson怎么像map容器那样遍历？

halx99
Tue, 21 Apr 2015 10:32:38 +0000

假设object集成自GenericValue, 可以写个成员函数，遍历代码如下：
template
void cforeach(_Operation op)
{
if(IsArray())
{
for (auto it = this->onBegin(); it != this->onEnd(); ++it)
op(static_cast<object&>(*it));
}
else if (IsObject())
{
for (auto it = this->MemberonBegin(); it != this->MemberonEnd(); ++it)
op(static_cast<object&>(*it));
}
}

阅读整个主题