From 7aa7f8f746b97218f64448d789a2af289c1fbfed Mon Sep 17 00:00:00 2001 From: Krateng Date: Wed, 8 May 2019 18:31:48 +0200 Subject: [PATCH] Now actually patching the JSON encoder bottle uses --- monkey.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/monkey.py b/monkey.py index d8f1215..125b116 100644 --- a/monkey.py +++ b/monkey.py @@ -1,6 +1,13 @@ # custom json encoding -from simplejson import JSONEncoder +# 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): return getattr(object.__class__,"__json__", olddefault)(object)