我是rapidjson
的新手,我的文字低于json
:
{"Response":"GetAllocations","ResponseCode":200,"ports":[0,1,2],"ports":[3,4,5], "ports":[6,7,8]}
如何按键0, 1, 2; 3, 4, 5; 6, 7, 8
提取值"ports"
?
提前致谢。
答案 0 :(得分:0)
啊,我的代码如下:
rapidjson::Document doc;
if (doc.Parse(sssss.c_str()).HasParseError() || !doc.IsObject() || !doc.HasMember("Response") || !doc["Response"].IsString())
{
return 0;
}
for (SizeType i = 0; i < doc["ports"].Size(); ++i)
{
cout << "id = " << doc["ports"][0].GetUint() << endl;
cout << "port1 = " << doc["ports"][1].GetUint() << endl;
cout << "port2 = " << doc["ports"][2].GetUint() << endl;
}