在RapidJson中循环遍历数组并获取对象元素

问题描述:

如何从ConstrValueIterator中获取值?在这种情况下,我知道数组的元素是字典(又称对象).

How do I get the value out of a ConstrValueIterator? In this case I know that the elements of the array are dictionaries (aka objects).

代码总结:

for (rapidjson::Value::ConstValueIterator itr = rawbuttons.Begin(); itr != rawbuttons.End(); ++itr) { // Ok
    if (itr->HasMember("yes")) { // Ok
        auto somestring = itr["yes"]->GetString(); // error
    }
}

Um.需要取消对迭代器的引用或对其进行调用.

Um. Iterators need to be dereferenced or whatever it's called.

for (rapidjson::Value::ConstValueIterator itr = rawbuttons.Begin(); itr != rawbuttons.End(); ++itr) { // Ok
    if (itr->HasMember("yes")) { // Ok
        auto somestring = (*itr)["yes"]->GetString(); // bingo
    }
}