make method instead of property for alternative json decoding of request
This commit is contained in:
parent
1d719252cb
commit
a8f764c161
|
@ -69,8 +69,18 @@ class Request(dict):
|
|||
self.stream = None
|
||||
|
||||
@property
|
||||
def json(self, loads=json_loads):
|
||||
def json(self):
|
||||
if self.parsed_json is None:
|
||||
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
|
||||
|
||||
def load_json(self, loads=json_loads):
|
||||
try:
|
||||
self.parsed_json = loads(self.body)
|
||||
except Exception:
|
||||
|
|
Loading…
Reference in New Issue
Block a user