Godot Version
Godot 4.7.1 stable
Question
I’ve been rewriting my save system recently for a number of reasons, one of the main ones being that I can keep the data I don’t want reset on a hard reset/on different save files in a seperate dictionary and save that. However, after making all the changes, I’m getting a “unicode parse error” (actual screenshot a little below).
I’m saving the following dictionary with the following code (there is other code, but it isn’t relevant to this, I tried isolating this exact code and it did the same thing)(yes, there is a seperate reason META_PATH is a var instead of a const. I used the all caps naming scheme because it originally was a constant and had to be later changed due to an error it caused).
var metadata = {
ID = 0,
white_seen = false,
savefile = 1,
fun = 0,
}
var META_PATH
func _save() -> void:
var file: FileAccess = FileAccess.open(META_PATH, FileAccess.WRITE)
if FileAccess.get_open_error(): push_error("Error opening persistent data!"); return
print(metadata)
print(Marshalls.variant_to_base64(metadata))
file.store_var(Marshalls.variant_to_base64(metadata))
file.close()
var file2: FileAccess = FileAccess.open(META_PATH, FileAccess.READ)
if FileAccess.get_open_error(): push_error("Error opening persistent data!"); return
print(file2.get_as_text())
file2.close()
func _ready() --> void:
META_PATH = "user://GAMEmetadata.json"
_save()
And I get the following in the logs from this (the ID and fun variables are randomized in the ready function if they are the default, just too lazy to copy that over);
![]()
I have absolutely no idea why this could be happening, given that it seems fine after it gets converted to base64. I’m fairly certain it has to do with the file.store_var() function, although I’m unsure what to do about that. I’m using this exact same save system for putting another dictionary into another file, and it works perfectly, as it had before I made any changes at all. Incase it’s relevant, the file is only used at runtime to copy the values over to be seen or changed in game. What gives? (Raw data from the file below).
