JSON encode arbitrary objects as string representationa

This commit is contained in:
Joel Collins 2019-11-29 11:33:26 +00:00
parent 49edf16883
commit 98d8993beb

View file

@ -35,7 +35,11 @@ class JSONEncoder(json.JSONEncoder):
else:
# call base class implementation which takes care of
# raising exceptions for unsupported types
return json.JSONEncoder.default(self, o)
try:
return json.JSONEncoder.default(self, o)
# if it's some mystery object, just return a string representation
except TypeError:
return str(o)
# MAIN CONFIG CLASS