Aggiunto modulo per la conversione degli oggetti in JSON

This commit is contained in:
Fabio Scotto di Santolo
2021-06-24 20:59:13 +02:00
parent a3e5229bfa
commit b53629ae6e
5 changed files with 15 additions and 9 deletions

View File

@@ -19,11 +19,11 @@ class Department:
def location_id(self) -> Location:
return self.__location
def to_json(self):
def __json__(self):
return {
'department_id': self.__department_id,
'name': self.__name,
'location': self.__location.to_json() if self.__location is not None else None
'location': self.__location if self.__location is not None else None
}
def __str__(self):