diff --git a/io/json_canon.gd b/io/json_canon.gd index f350ab7..7cf263f 100644 --- a/io/json_canon.gd +++ b/io/json_canon.gd @@ -65,7 +65,7 @@ static func _canon_group(gd: Dictionary) -> Dictionary: if str(m) != "" and not members.has(str(m)): members.append(str(m)) g["members"] = members - _keep(gd, g, ["parent"]) + _keep(gd, g, ["parent", "color"]) return g diff --git a/tests/test_io.gd b/tests/test_io.gd index b592e15..f628584 100644 --- a/tests/test_io.gd +++ b/tests/test_io.gd @@ -56,6 +56,10 @@ func _test_json() -> void: var res2 := JsonIO.import_json(JsonIO.export_json(small)) _check(res2["ok"] and res2["collection"] == JsonIO.canonical(small), "small spread round-trips exactly") _check(not JsonIO.export_json({"tables": [], "state": {"draws": 1}}).contains("state"), "export drops unknown/local keys") + var coloured := _small() + coloured["groups"] = [{"id": "g1", "name": "Gear", "members": ["loot"], "color": "#7a3fa8"}] + var cres := JsonIO.import_json(JsonIO.export_json(coloured)) + _check(cres["ok"] and cres["collection"]["groups"][0].get("color", "") == "#7a3fa8", "a group's colour survives export and import") # Legacy keys: triggers, die, collection name. var legacy := JsonIO.import_json('{"format_version":1,"collection":"Old","tables":[{"id":"a","name":"A","die":20,"entries":[{"text":"x","triggers":["a"]}]}]}')