JSON Resource Type

There does not seem to be a way to add a JSON file to GDevelop that will be usable during preview and after export. FileSystem::ExecutableFolderPath() only works after exporting the game, and you’d have to manually put any JSON data files into that path after exporting… which makes it hard to test during preview.
It’s easy to read JSON from a file, but there’s no way to reliably ensure the files that you design against are an integrated part of the project like other “Resources”.

This could just be a binary or flat file resource type as well, it doesn’t have to be JSON, the only real requirement is the ability to include a file in your project that will be there at test and execution time, and a method or function that allows you to reference that file reliably… perhaps FileSystem::ResourcePath().

As a heads up, executable path works fine (just tested). But it is based off where the game is running.

In preview, this means the GDevelop install directory. So to test this, just put your json file there as a workaround.

The above said, I still think there is a value in it being a valid resource type.

I should have stated that better, yes FileSystem::ExecutableFolderPath() works from preview, but it’s not where your development files are… but after exporting it is where the game files are.

There is already a json resource type (for the yarn dialogue), just no action to get the content of one :stuck_out_tongue: It should be pretty easy to add and I have been thinking about it for some time as well, +1

Do you know if this feature has been added?

I’m doing a scalar field editor example for the Marching Squares extension and it would be great to be able to embed JSON files to use them as levels even in a web browser.

It will try to add the feature if it doesn’t exist.

I’ve implemented it but it has not been accepted :man_shrugging:

1 Like