return valid json in request.json

This commit is contained in:
Raphael Deem
2017-03-06 00:33:34 -08:00
parent 19592e8eea
commit 90138c4bae
2 changed files with 15 additions and 5 deletions

View File

@@ -69,6 +69,8 @@ class Request(dict):
try:
self.parsed_json = json_loads(self.body)
except Exception:
if not self.body:
return None
raise InvalidUsage("Failed when parsing body as json")
return self.parsed_json