Improve jsonification

This commit is contained in:
Matthias
2019-05-11 13:31:48 +02:00
parent 557f849519
commit a146c5bf78
2 changed files with 25 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import logging
import threading
from datetime import datetime, date
from ipaddress import IPv4Address
from typing import Dict
@@ -18,6 +19,10 @@ class ArrowJSONEncoder(JSONEncoder):
try:
if isinstance(obj, Arrow):
return obj.for_json()
elif isinstance(obj, date):
return obj.strftime("%Y-%m-%d")
elif isinstance(obj, datetime):
return obj.strftime("%Y-%m-%d %H:%M:%S")
iterable = iter(obj)
except TypeError:
pass