diff --git a/data/category.py b/data/category.py index bf5c7e5..0dfe128 100644 --- a/data/category.py +++ b/data/category.py @@ -1,6 +1,7 @@ """File for Category class.""" from typing import Optional +import json from data.score import Score, ScoreTime # pylint: disable=import-error @@ -21,14 +22,7 @@ class Category: def __str__(self) -> str: """Creates a string from the class.""" - ret_str = f"{self.name}\n" - ret_str += f"ascending: {self.ascending}\n" - ret_str += f"time_record: {self.time_record}" - - for score in self.scores: - ret_str += f"{score}\n" - - return ret_str + return json.dumps(self.to_dict(), indent=4) @property def ascending(self) -> bool: @@ -87,6 +81,7 @@ class Category: data = {} data["ascending"] = self.ascending data["time_record"] = self.time_record + data["scores"] = {} for score in self.scores: data["scores"][score.user] = score.score