Last active
April 6, 2021 18:45
-
-
Save bruchmann/18462c9a793ccbb09cf8eb6b9dd920f5 to your computer and use it in GitHub Desktop.
Read a JSON file in GDScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func read_json_file(path: String): | |
var file = File.new() | |
file.open(path, File.READ) | |
var json_result = JSON.parse(file.get_as_text()) | |
if not json_result.error == OK: | |
return {} # Silently fail | |
return json_result.result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment