force return json instead of raise error for request.json
This commit is contained in:
parent
cb825687a5
commit
2b4dbee33d
1 changed files with 15 additions and 0 deletions
|
|
@ -51,6 +51,21 @@ class Request(RequestBase):
|
|||
#: something similar.
|
||||
routing_exception: Exception | None = None
|
||||
|
||||
@property
|
||||
def json(self) -> t.Any | None:
|
||||
"""The parsed JSON data if :attr:`mimetype` indicates JSON
|
||||
(:mimetype:`application/json`, see :attr:`is_json`).
|
||||
|
||||
Calls :meth:`get_json` with default arguments.
|
||||
|
||||
If the request content type is not ``application/json``, this
|
||||
will return empty object.
|
||||
|
||||
.. versionchanged:: 2.3
|
||||
force return json instead of raise a 415 Unsupported Media Type error.
|
||||
"""
|
||||
return self.get_json(force=True)
|
||||
|
||||
@property
|
||||
def max_content_length(self) -> int | None: # type: ignore
|
||||
"""Read-only view of the ``MAX_CONTENT_LENGTH`` config key."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue