Fixed toJson methods

This commit is contained in:
2025-11-18 23:46:32 +01:00
parent 2da2e28cb6
commit fd86f5193f
3 changed files with 13 additions and 9 deletions

View File

@@ -35,7 +35,11 @@ class Game {
winner = json['winner'] ?? ''; winner = json['winner'] ?? '';
/// Converts the Game instance to a JSON object. /// Converts the Game instance to a JSON object.
String toJson() { Map<String, dynamic> toJson() => {
return 'Game{id: $id,name: $name,players: $players,group: $group,winner: $winner}'; 'id': id,
} 'name': name,
'players': players?.map((player) => player.toJson()).toList(),
'group': group?.toJson(),
'winner': winner,
};
} }

View File

@@ -23,7 +23,9 @@ class Group {
.toList(); .toList();
/// Converts the Group instance to a JSON object. /// Converts the Group instance to a JSON object.
String toJson() { Map<String, dynamic> toJson() => {
return 'Group{id: $id, name: $name,members: $members}'; 'id': id,
} 'name': name,
'members': members.map((member) => member.toJson()).toList(),
};
} }

View File

@@ -17,7 +17,5 @@ class Player {
name = json['name']; name = json['name'];
/// Converts the Player instance to a JSON object. /// Converts the Player instance to a JSON object.
String toJson() { Map<String, dynamic> toJson() => {'id': id, 'name': name};
return 'Player{id: $id,name: $name}';
}
} }