Exported project crashes (Error: file must be opened before use)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheJollyReaper
ERROR: File must be opened before use.
At: core/bind/core_bind.cpp:2023
ERROR: parse: Error parsing JSON at line 0:
At: core/bind/core_bind.cpp:3220
ERROR: File must be opened before use.
At: core/bind/core_bind.cpp:2023
ERROR: parse: Error parsing JSON at line 0:
At: core/bind/core_bind.cpp:3220

This is where I assume the problem is, because the only place I deal with files is while saving/loading

# Save Game
func save():
var save = File.new()
save.open("user://%s.json"%player_name, File.WRITE)
var save_dict = {
	"player_name":player_name,
	"player_health_max":player_health_max,
	"player_health":player_health,
	"player_attack":player_attack,
	"player_defense":player_defense,
	"player_speed":player_speed,
	"room":room
}
save.store_line(to_json(save_dict))
save.close()

func load(name):
var file = File.new()
file.open("user://%s"%name, File.READ)
var data = file.get_as_text()
var json_result = JSON.parse(data)
var dict = json_result.result
player_health_max = dict["player_health_max"]
player_health = dict["player_health"]
player_attack = dict["player_attack"]
player_defense = dict["player_defense"]
player_speed = dict["player_speed"]
room = dict["room"]
file.close()
goto_scene("res://scenes/dungeon.tscn")

I don’t have any issues testing the game in editor, but once it’s exported (windows desktop) the errors pop up.

:bust_in_silhouette: Reply From: TheJollyReaper

After some significant googling time, I found the solution. I added “*.json” to the export filters and it took care of the issue.

OH MY GOD THANKS!
I’ve been searching this for more than an hour

Lfzinho | 2021-12-19 21:54