标签:rapidjson cocos2dx c++ 遍历 json
要被解析遍历的json(存放在BaccaratBettingBoard.json文件中):
{ "1001":[271,3,536,171], "1002":[3,3,269,171], "1003":[173,173,357,297], "1006":[360,173,536,297], "1007":[3,173,171,297] }
std::string load_str; load_str = FileUtils::getInstance()->getStringFromFile("BaccaratBettingBoard.json"); rapidjson::Document readdoc; readdoc.Parse<0>(load_str.c_str()); if(readdoc.HasParseError()) { log("GetParseError%s\n", readdoc.GetParseError()); } CCASSERT(readdoc.IsObject(), "bettingBoard::initBettingBoard: 读取json失败,无法初始化下注区!"); for(auto iter = readdoc.MemberonBegin(); iter != readdoc.MemberonEnd(); ++iter) { auto key = (iter->name).GetString(); log("key:%s", key); log("value:"); //auto& v = readdoc[key] for(auto i = 0; i < readdoc[key].Size(); ++i) { log("%0.2f", readdoc[key][i].GetDouble()); } }
标签:rapidjson cocos2dx c++ 遍历 json
原文地址:http://blog.csdn.net/benthy2/article/details/44404951