From b447fb9f21e6690c39b58f24d92bbed493855d6b Mon Sep 17 00:00:00 2001 From: Mike Rinehart Date: Fri, 13 Oct 2017 17:16:53 -0500 Subject: [PATCH] Add get json serializable function --- whois/_3_adjust.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/whois/_3_adjust.py b/whois/_3_adjust.py index 336447e..6777357 100644 --- a/whois/_3_adjust.py +++ b/whois/_3_adjust.py @@ -47,6 +47,17 @@ def __init__(self, data): except KeyError: pass + def get_json_serializable(self): + properties = self.__dict__ + + for key in properties: + if type(properties[key]) is datetime.datetime: + properties[key] = properties[key].isoformat() + if type(properties[key]) is set: + properties[key] = list(properties[key]) + + return properties + # http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_FORMATS = [