Sys.load_resource fails when loading json (SOLVED)


Hey everyone!

For my game (a currently unnamed RPG project) I wanted to create a dialog tree system. For this system I created a custom c# application that exports .json files in the format and with the information I need it to. The problem is that I cannot get Defold to properly load the files at all.

I have checked with an online JSON validator online to confirm that the JSON is in fact legitimate.

The problem seems to be linked entirely with the sys.load_resource() function. Whenever I attempt to use it, I get the error message:
Error: Failed to load resource: /main/level/levelList/SampleNPCArea/convos/sampleConvo1.json (-3) .

I am loading it like this:
local info = “”
local errorText = “”
info, errorText = sys.load_resource("/main/level/levelList/SampleNPCArea/convos/sampleConvo1.json")
return json.decode(info)

I saw in this documentation ( that I am suppose to do something with the Custom Resources setting in “game.project”. I have attempted to link the json file to that but it still fails.

I have tried copying and pasting the json file contents into a standard .txt but that fails to load too.

I have tried everything I can think of to trouble shoot. I have no idea that the (-3) means. Any suggestions for what I can try?

Thanks in advance!



I believe the problem is not related to your json file/format. It is probably because of your “Custom Resources” setting is not correct.
Documentation is here:

custom-resources path should be: main/level/levelList/SampleNPCArea/convos/sampleConvo1.json and afaik it is “case sensitive”.



Finally got around to fixing it and this was extremely helpful! The Custom Resource setting in the game.project file was incorrect, it is working now!

Thank you!

1 Like