Failed to parse JSON [SOLVED]

Hello,

I am trying to parse JSON with sys.load_resource("/main/1.json")

I get this error:

Failed to parse json '{
	"name": "test"
}' (-1).

It is a fairly simple JSON, and no matter what I put inside it, I get this error. Could it be something to do with the encoding of the file? I am using a Mac and Sublime text to create the file.

Thanks.

1 Like

Guessing you solved it by adding it as a custom resource in game.project?

1 Like

Actually, I had the game.project done correctly. The bug seemed to be in the encoding, as I created a new file with same JSON and it worked.

About game.project, it brings me to another question: how can I put more than one file in custom_resources? Right now I have

custom_resources = /main/story/es/1.json

If I want to put also “2.json” and “3.json”, how can I do it? like:

custom_resources = /main/story/es/1.json, /main/story/es/2.json, /main/story/es/3.json

?

Thanks!

1 Like

You can either comma separate the files or point to a folder with files to include.

2 Likes

Nice!

So I could do

custom_resources = /main/story/es/

?

Thanks

Yes, that should work. Give it a try!

1 Like

Didn’t work, I get:

Errors running builder 'Content Builder' on project 'X'.
Build failed: /Users/X/Downloads/Defold-macosx.cocoa.x86_64/branches/27359/10279/local/main/story/es (Is a directory)

Try removing the last / (ie /main/story/es). And if that doesn’t work, try to also remove the initial / (ie main/story/es)

2 Likes

main/story/es did the trick! Thanks!

3 Likes