• Building
  • problems exporting/reading json files to android

Hi everyone hope you are having a good day/night.

I`m trying to read some data from a json file using

var ItemList = System.IO.File.ReadAllText("user://ItemList.json");

and Im not sure if the files just arent expotred at all or if I`m using the wrong path.

if I use the initial path like "ItemList.json" I get an unauthorized access exception on android, but it works on windows.

I changed it up to "user://ItemList.json" and now its just directory not found on both platforms. Even if I create a new file in case ItemList.json doesnt exist it`s still the same exception. I attached the script where it all happens below

Can anyone provide some help please?

I think you need to use Godot's File class if you want to use paths like user://. So instead of System.IO.File.ReadAllText("user://ItemList.json");, you instead will need to use something like (untested):

var ItemListFile = new File();
ItemListFile.Open("user://ItemList.json");
var ItemList = ItemListFile.ReadAsText();