fix(@projects/@magic-civilization): 🐛 handle mixed json array/object parsing
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
96cb08ec04
commit
af7992eb7f
1 changed files with 13 additions and 6 deletions
|
|
@ -187,12 +187,19 @@ func _apply_runtime_units_catalog(gs: RefCounted) -> void:
|
|||
if f != null:
|
||||
var raw: String = f.get_as_text()
|
||||
f.close()
|
||||
# Per-unit file is a single object — wrap all into one
|
||||
# array to ship in one call. Rust loader accepts both
|
||||
# object and array shapes; we always send an array.
|
||||
var parsed: Dictionary = JSON.parse_string(raw) as Dictionary
|
||||
if parsed != null and not parsed.is_empty():
|
||||
entries.append(parsed)
|
||||
# Per-unit file is either a single object or a single-element
|
||||
# array (canonical post-data-architecture migration is array-
|
||||
# rooted; pre-migration is object-rooted). Accept both shapes.
|
||||
# Rust loader accepts an array; we always ship one.
|
||||
var parsed_arr: Array = JSON.parse_string(raw) as Array
|
||||
if parsed_arr != null:
|
||||
for item: Dictionary in parsed_arr:
|
||||
if not item.is_empty():
|
||||
entries.append(item)
|
||||
else:
|
||||
var parsed_obj: Dictionary = JSON.parse_string(raw) as Dictionary
|
||||
if parsed_obj != null and not parsed_obj.is_empty():
|
||||
entries.append(parsed_obj)
|
||||
fname = dir.get_next()
|
||||
dir.list_dir_end()
|
||||
if entries.is_empty():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue