Browse Source

Merge pull request #2353 from grantwwu/patch-1

Clarify documentation for json parsing
pull/2354/head
David Lord 8 years ago committed by GitHub
parent
commit
49f3e96844
  1. 13
      flask/wrappers.py

13
flask/wrappers.py

@ -97,8 +97,9 @@ class Request(RequestBase):
@property
def json(self):
"""If the mimetype is :mimetype:`application/json` this will contain the
parsed JSON data. Otherwise this will be ``None``.
"""If the request has a JSON mimetype like :mimetype:`application/json`
(see :meth:`is_json`), this will contain the parsed JSON data.
Otherwise this will be ``None``.
The :meth:`get_json` method should be used instead.
"""
@ -124,10 +125,10 @@ class Request(RequestBase):
def get_json(self, force=False, silent=False, cache=True):
"""Parses the incoming JSON request data and returns it. By default
this function will return ``None`` if the mimetype is not
:mimetype:`application/json` but this can be overridden by the
``force`` parameter. If parsing fails the
:meth:`on_json_loading_failed` method on the request object will be
this function will return ``None`` if the request does not use a JSON
mimetype like :mimetype:`application/json`. See :meth:`is_json`. This
can be overridden by the ``force`` parameter. If parsing fails,
the :meth:`on_json_loading_failed` method on the request object will be
invoked.
:param force: if set to ``True`` the mimetype is ignored.

Loading…
Cancel
Save