I have a json file which is read using a rapidjson. I assign the value of my variables of data from a file. But when I use them later in the code, they are empty and but i don’t understand why. Somebody help me?
void MyClass::initVariables() {
std::string fullPath = CCFileUtils::fullPathFromRelativePath("file.json");
const char* mFileData = NULL;
unsigned long bufferSize = 0;
mFileData = (const char*)CCFileUtils::getFileData(fullPath.c_str(), "r", &bufferSize);
Document document; //rapidjson Document
if (!document.Parse<0>(mFileData).HasParseError()) {
const Value& data = document["words"][SizeType(numShape)];
mShape = data["shape"].GetString();
mTexture = data["texture"].GetString();
mName = data["name"].GetString();
CCLog("mTexture : %s", mTexture); //there mTexture is not empty = "texture.png"
}
delete[] mFileData;
}
***
some code
***
void MyClass::initShape() {
mShape->setTexture(mTexture); // mTexture is empty;
}