Skip to content

Commit

Permalink
处理clickhouse特殊数据类型序列化问题 (#1525)
Browse files Browse the repository at this point in the history
* 处理clickhouse特殊数据类型序列化问题

* 修改为在extend_json_encoder中处理
  • Loading branch information
nick2wang authored May 19, 2022
1 parent f1d8677 commit 5a7d666
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions common/utils/extend_json_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from decimal import Decimal
from datetime import datetime, date, timedelta
from functools import singledispatch
from ipaddress import IPv4Address, IPv6Address
from uuid import UUID


@singledispatch
Expand Down Expand Up @@ -41,6 +43,21 @@ def _(o):
return list(o)


@convert.register(UUID)
def _(o):
return str(o)


@convert.register(IPv4Address)
def _(o):
return str(o)


@convert.register(IPv6Address)
def _(o):
return str(o)


class ExtendJSONEncoder(json.JSONEncoder):
def default(self, obj):
try:
Expand Down

0 comments on commit 5a7d666

Please sign in to comment.