Write employee information to a JSON file
with open(‘employee.json’, ‘w’) as file:
json.dump({‘employees’: employees}, file, indent=2)
import json
from datetime import datetime
class Employee:
def init(self, name, dob, height, city, state):
self.name = name
self.dob = dob
self.height = height
self.city = city
self.state = state
def __str__(self):
return f"Name: {self.name}, DOB: {self.dob}, Height: {self.height}, City: {self.city}, State: {self.state}"
Read employee information from the JSON file
with open(‘employee.json’, ‘r’) as file:
data = json.load(file)
employee_data = data[‘employees’]
Create a list of Employee objects
employees_list = []
for emp_info in employee_data:
employee = Employee(emp_info[‘Name’], emp_info[‘DOB’], emp_info[‘Height’], emp_info[‘City’], emp_info[‘State’])
employees_list.append(employee)
Print the list of Employee objects
for emp in employees_list:
print(employee_data)
Please someone help…