Friday, June 6, 2025
spot_img

Useful resource Loading Error in Cocos Creator – Cocos Creator


I’m making an attempt to load a JSON obj from a file in Cocos Creator utilizing the next code:

assets.load("level1.json", JsonAsset, (err, levelData) => {
     if (err) {
         console.error('Didn't load Degree Information:', err);
         return;
     }
     else //Do One thing
}

The stated file is current in assets folder, however I’m nonetheless getting this error when making an attempt to play the sport:

Didn’t load Degree Information: Error: Can’t parse this enter:{“path”:“level1”,“requestType”:“path”,“bundle”:“”,“preset”:“default”,“precedence”:0}

Have tried the next:

  • Play in Editor
  • Play in Browser
  • Filename with Extension (“level1.json”)
  • Filename with out Extension (“level1”)

However none of those labored. Anybody has any thought the right way to repair this difficulty?

Hello, you need to take away the extension half .json from the trail of the filename.
Do that

assets.load("level1", JsonAsset, (err, levelData) => {
     if (err) {
         console.error('Didn't load Degree Information:', err);
         return;
     }
     else //Do One thing
}

@tuan243 thanks for the reply. I had tried that as properly, but it surely didn’t work both. Is there the rest that may very well be a problem?

That’s bizarre, I attempted

assets.load("check", JsonAsset, (err, information) => {
      if (err != null) {
        console.error(err);
        return;
      }

      console.log("json information", information);
    });

And right here is the outcome. I efficiently log it out. I’m utilizing Cocos 3.8.6

Thanks lots for the assistance Tuan. Discovered the difficulty. My assets folder was not within the root (property) folder of the undertaking, which was inflicting the difficulty.

Now it’s sorted!



1 Like

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles