For string body make sure we serialize unicode properly
This commit is contained in:
@@ -21,7 +21,11 @@ class JSONSerializer(object):
|
||||
def dumps(self, data):
|
||||
# don't serialize strings
|
||||
if isinstance(data, (type(''), type(u''))):
|
||||
return data
|
||||
try:
|
||||
return data.encode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
# Python 2 and str, no need to re-encode
|
||||
return data
|
||||
|
||||
try:
|
||||
return json.dumps(data, default=self.default)
|
||||
|
||||
Reference in New Issue
Block a user