1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Liverpool 4 Barcelona 0

This commit is contained in:
Krateng 2019-05-08 18:44:39 +02:00
parent 7aa7f8f746
commit f42c1b5ed3

View File

@ -1,19 +1,32 @@
# custom json encoding # custom json encoding
# make sure we use the json encoder that bottle uses
try:
from simplejson import JSONEncoder
except ImportError:
try:
from json import JSONEncoder
except ImportError:
from django.utils.simplejson import JSONEncoder
def newdefault(self,object): def newdefault(self,object):
return getattr(object.__class__,"__json__", olddefault)(object) return getattr(object.__class__,"__json__", self._olddefault)(object)
olddefault = JSONEncoder.default
# just patch every encoder
try:
from simplejson import JSONEncoder
JSONEncoder._olddefault = JSONEncoder.default
JSONEncoder.default = newdefault 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