Added fromJson, toJson

This commit is contained in:
2025-11-18 23:16:57 +01:00
parent 07d623d963
commit d86de09042
3 changed files with 40 additions and 0 deletions

View File

@@ -13,4 +13,17 @@ class Group {
String toString() {
return 'Group{id: $id, name: $name,members: $members}';
}
/// Creates a Group instance from a JSON object.
Group.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'],
members = (json['members'] as List)
.map((memberJson) => Player.fromJson(memberJson))
.toList();
/// Converts the Group instance to a JSON object.
String toJson() {
return 'Group{id: $id, name: $name,members: $members}';
}
}