I am trying to load a JSON in the simulation mode. I have my file placed at -
assets/Test.json. I have verified the file exists and is saves as a JSON file. It gives me the following error -
“Can not parse this input:{“path”:“Test.json”,“preset”:“default”,“priority”:0}”
What could be going wrong ?
My code is as following -
"try {
return await this.loadLocalJson('Test.json' /*GameConfigProxy.json'*/); // Update the path as necessary
// return this.loadTextFile('config/Test1.txt');
}
catch (error) {
console.error("Error loading JSON:", error);
}"
async loadLocalJson(path: string): Promise {
return new Promise((resolve, reject) => {
assetManager.loadAny({ path: path, type: JsonAsset }, (err, assets) => {
if (err) {
reject(err);
return;
}
if (assets instanceof JsonAsset) {
const jsonAssets = assets as JsonAsset;
const jsonData = jsonAssets.json;
// Access properties directly from jsonData
console.log('Test Data:', jsonData);
//console.log('Slot Game Config Data:', jsonData.slotGameConfigData);
resolve(assets.json);
} else {
reject(new Error('Asset is not a valid JSON'));
}
});
});
}