首先,创建
然后
再导出数据:
再然后,能够看到数据的格式是:
再然后,就是
数据解析代码:
[cpp] view
plaincopy
- //////////////////
- rapidjson::Document _doc;
- bool bRet = false;
- unsigned long size = 0;
- unsigned char *pBytes = NULL;
- do {
- pBytes = cocos2d::CCFileUtils::sharedFileUtils()->getFileData("Book1.json", "r", &size);
- CC_BREAK_IF(pBytes == NULL || strcmp((char*)pBytes, "") == 0);
- std::string load_str((const char*)pBytes, size);
- CC_SAFE_DELETE_ARRAY(pBytes);
- _doc.Parse<0>(load_str.c_str());
- CC_BREAK_IF(_doc.HasParseError());
- //CCLOG("helloworld:%d", DICTOOL->getIntValue_json(_doc, "layer"));
- //DICTOOL->getIntValue_json(_doc, "layer");
- //auto temp = _doc["row0"].GetString();
- //DICTOOL->getDictionaryFromArray_json(_doc,"layer",1);
- CC_BREAK_IF(!_doc.IsArray());
- CCLOG("ffff:%d",_doc.GetType());
- for (rapidjson::SizeType i = 0; i < _doc.Size(); i++)
- {
- const rapidjson::Value &p = _doc[i];
- /////////////////////在这里写下你处理语句
- CCLOG("rrrr:%d", p["row2"].GetInt());
- ////////////////////////////////////////
- }
- bRet = true;
- } while (0);
- //////////////////
时间: 2024-10-28 22:20:15