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

@@ -62,14 +62,14 @@ class Employee(Person):
def manager_id(self) -> int:
return self.__manager_id
def to_json(self):
def __json__(self):
return {
'employee_id': self.__employee_id,
'first_name': self.first_name,
'last_name': self.last_name,
'email': self.__email,
'hire_date': f"{self.__hire_date: %Y-%m-%d}",
'department': self.__department.to_json() if self.__department is not None else None,
'hire_date': self.__hire_date,
'department': self.__department if self.__department is not None else None,
'job_id': self.__job_id,
'salary': f"{self.__salary:,.2f}",
'manager_id': self.__manager_id