diff --git a/common/utils/extend_json_encoder.py b/common/utils/extend_json_encoder.py index 69f69620dd..d7c525b8bb 100644 --- a/common/utils/extend_json_encoder.py +++ b/common/utils/extend_json_encoder.py @@ -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 @@ -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: