请把代码粘贴在这里
```
Widget* GUIReader::widgetFromJsonFile(const char *fileName)
{
std::string jsonpath;
rapidjson::Document jsonDict;
jsonpath = fileName;
// jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
size_t pos = jsonpath.find_last_of('/');
m_strFilePath = jsonpath.substr(0,pos+1);
std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonpath);
jsonDict.Parse<0>(contentStr.c_str());
if (jsonDict.HasParseError())
{
CCLOG("GetParseError %s\n",jsonDict.GetParseError());
}
Widget* widget = nullptr;
const char* fileVersion = DICTOOL->getStringValue_json(jsonDict, "version");
WidgetPropertiesReader * pReader = nullptr;
if (fileVersion)
{
int versionInteger = getVersionInteger(fileVersion);
if (versionInteger < 250)
{
pReader = new (std::nothrow) WidgetPropertiesReader0250();
widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName);
}
else
{
pReader = new (std::nothrow) WidgetPropertiesReader0300();
widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName);
}
}
else
{
pReader = new (std::nothrow) WidgetPropertiesReader0250();
widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName);
}
CC_SAFE_DELETE(pReader);
return widget;
}
上面还有一句“jsonfile = filename”,