rapidjson提取键和值 [英] rapidjson extract key and value

查看:3052
本文介绍了rapidjson提取键和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图提取键和数组中的对象的值,但没有找到正确的getter:

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?

推荐答案

假设V是一个具有键值对象的JSON对象。您可以检索这样的数据。

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());
}

这篇关于rapidjson提取键和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆