0 votes

I’m rewriting a storage system and ran into an interesting problem. There was an error where I did not change anything. Literally, a minute ago it started and even loaded values ​​- now an error has appeared.

func load_save() -> Dictionary:
var f := File.new()
f.open("res://slot.json", File.READ)
var result := JSON.parse(f.get_as_text())
if result.error:
    printerr("Failed to parse save file: ", f.error_string)
return result.result as Dictionary

Error: Invalid get index 'errorstring' (on base: 'File').

I already rolled everything back, but it didn’t fix anything

in Engine by (71 points)

Rewrite this again - and it works, lol

1 Answer

0 votes

error_string is a property on a JSONParseResult object. You're referencing it as if it's a property on a File object.

I think you want result.error_string instead of f.error_string...

by (13,082 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.