Switched to try/except

This commit is contained in:
Jakob Bowyer 2017-03-02 15:16:01 +00:00
parent 53b61d13f9
commit 5f140048f4

View File

@ -10,8 +10,10 @@ except ImportError:
from json import loads as _json_loads
def json_loads(i):
i = i.decode() if isinstance(i, bytes) else i
return _json_loads(i)
try:
return _json_loads(i.decode())
except AttributeError:
return _json_loads(i)
from sanic.exceptions import InvalidUsage
from sanic.log import log