Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def newdefault(self,object):
return getattr(object.__class__,"__json__", self._olddefault)(object)
# just patch every encoder
try:
from simplejson import JSONEncoder
JSONEncoder._olddefault = JSONEncoder.default
JSONEncoder.default = newdefault
except:
pass
try:
from json import JSONEncoder
JSONEncoder._olddefault = JSONEncoder.default
JSONEncoder.default = newdefault
except:
pass
try:
from ujson import JSONEncoder
JSONEncoder._olddefault = JSONEncoder.default
JSONEncoder.default = newdefault
except:
pass
# proper sunday-first weeks
# damn iso heathens