Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. class EnhancedJSONEncoder(json.JSONEncoder):
  2. def default(self, o):
  3. if is_dataclass(o):
  4. return asdict(o)
  5. if isinstance(o, Enum):
  6. return o.name
  7. if isinstance(o, time):
  8. return o.strftime("%H:%M")
  9. return super().default(o)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement