mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 06:31:41 +08:00
17 lines
336 B
Python
17 lines
336 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import json
|
|
import dataclasses
|
|
|
|
from nonebot.typing import overrides
|
|
|
|
|
|
class DataclassEncoder(json.JSONEncoder):
|
|
|
|
@overrides(json.JSONEncoder)
|
|
def default(self, o):
|
|
if dataclasses.is_dataclass(o):
|
|
return dataclasses.asdict(o)
|
|
return super().default(o)
|