mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-24 16:26:02 +03:00
generalize JSON serializer (#16733)
This commit is contained in:
parent
d481ab3a6a
commit
1d55fa894f
@ -1,6 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
@ -15,7 +14,7 @@ class EnhancedJSONEncoder(json.JSONEncoder):
|
||||
"""
|
||||
|
||||
def default(self, o: Any) -> Any:
|
||||
if dataclasses.is_dataclass(o):
|
||||
if hasattr(type(o), "to_json_dict"):
|
||||
return o.to_json_dict()
|
||||
elif isinstance(o, WalletType):
|
||||
return o.name
|
||||
|
Loading…
Reference in New Issue
Block a user