I’m trying to load a JSON obj from a file in Cocos Creator using the following code:
resources.load("level1.json", JsonAsset, (err, levelData) => {
if (err) {
console.error('Failed to load Level Data:', err);
return;
}
else //Do Something
}
The said file is present in resources
folder, but I’m still getting this error when trying to play the game:
Failed to load Level Data: Error: Can not parse this input:{“path”:“level1”,“requestType”:“path”,“bundle”:“”,“preset”:“default”,“priority”:0}
Have tried the following:
- Play in Editor
- Play in Browser
- Filename with Extension (“level1.json”)
- Filename without Extension (“level1”)
But none of these worked. Anyone has any idea how to fix this issue?