Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rapidjson extract key and value

I'm trying to extract the key and the value of an object in array but don't find the proper getter:

 for (Value::ConstValueIterator itr = document["params"].Begin(); itr != document["params"].End(); ++itr)
{
    for (Value::MemberIterator m = itr->MemberBegin(); m != itr->.MemberEnd(); ++m) {

    }       
}

in the second loop, I want to extract the key and value from the iterator separately. how to do the extraction?

like image 745
Pooya Avatar asked May 27 '14 10:05

Pooya


1 Answers

Suppose V is a JSON object which has key-value object. You can retrieve data like this.

const rapidjson::Value& V;
for (Value::ConstMemberIterator iter = V.MemberBegin(); iter != V.MemberEnd(); ++iter){
    printf("%s\t", iter->name.GetString());
    printf("%s\t", iter->value.GetString());
}
like image 106
einverne Avatar answered Oct 26 '22 08:10

einverne