[backport] Auto coerce bytes to string on own json module.a
Only for tests.remotes/origin/enhancement/email-actions
parent
ae5ca20a76
commit
b85eb8914c
|
@ -16,13 +16,15 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from rest_framework.utils import encoders
|
from rest_framework.utils import encoders
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
|
|
||||||
def dumps(data, ensure_ascii=True, encoder_class=encoders.JSONEncoder):
|
def dumps(data, ensure_ascii=True, encoder_class=encoders.JSONEncoder):
|
||||||
return json.dumps(data, cls=encoder_class, indent=None, ensure_ascii=ensure_ascii)
|
return json.dumps(data, cls=encoder_class, indent=None, ensure_ascii=ensure_ascii)
|
||||||
|
|
||||||
|
|
||||||
def loads(data):
|
def loads(data):
|
||||||
|
if isinstance(data, bytes):
|
||||||
|
data = force_text(data)
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
|
|
||||||
# Some backward compatibility that should
|
# Some backward compatibility that should
|
||||||
|
|
Loading…
Reference in New Issue