本文介绍了Rapidjson需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我从Web服务器接收JSON数组,想知道是否有一种方法使用rapidjson按顺序访问字段值,示例代码中的字段id始终存在但是title 根据内容可能会有所不同



  for (SizeType i =  0 ; i< result_loop.Size(); i ++)
{
cout<< result_loop [i] [ id]。GetInt()<< - << result_loop [i] [ title]。GetString()<< \ n;
}





对不起泡沫



我尝试过:



for(SizeType i = 0; i< result_loop.Size(); i ++)

{

std :: cout<< result_loop [i] [id]。GetInt()<< - << result_loop [i] [title]。GetString()<< \ n;

}

解决方案

Hi all I'm receiving a JSON array from a Web server and would like to know if there is a way using rapidjson to access field values by ordinal, the field "id" in the example code is always present but "title" can be different depending on the content

for (SizeType i = 0; i < result_loop.Size(); i++)
{
    cout << result_loop[i]["id"].GetInt() << " - " << result_loop[i]["title"].GetString() << "\n";
}



sorry about the fomatting

What I have tried:

for (SizeType i = 0; i < result_loop.Size(); i++)
{
std::cout << result_loop[i]["id"].GetInt() << " - " << result_loop[i]["title"].GetString() << "\n";
}

解决方案


这篇关于Rapidjson需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 22:22