mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 03:15:24 +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)
|