ChocolateBird/scripts/loaders/common.gd

14 lines
332 B
GDScript3
Raw Normal View History

2023-07-28 15:57:21 +09:30
extends Node
func load_json(filename: String) -> Dictionary:
var file := File.new()
var error := file.open(filename, File.READ)
if error == OK:
var result = JSON.parse(file.get_as_text())
if result.error == OK:
return result.result
else:
print_debug(result.error_string)
print_debug(result.error_line)
return {}