mention mimetype and is_json
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent daf85d3 · Browse files · 1 file·+12 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+12 added−10 removed
- other:+12 added−10 removed
Provenance
- Commit
217d5f9- Tree
7283aa1- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
daf85d3
1 file changed+12 added−10 removed
modified:flask/wrappers.py+12 added-10 removed
95 unmodified lines96 return self.url_rule.endpoint.rsplit('.', 1)[0]97 98 @property99 def json(self):100- """If self.is_json would return true, this will contain the101- parsed JSON data. Otherwise this will be ``None``.100+ """If the request has a JSON mimetype like :mimetype:`application/json`101+ (see :meth:`is_json`), this will contain the parsed JSON data.102+ Otherwise this will be ``None``.103 104 The :meth:`get_json` method should be used instead.105 """106 from warnings import warn2 unmodified lines109 return self.get_json()110 111 @property112 def is_json(self):112- """Indicates if this request is JSON or not. By default a request113+ """Indicates if this request is JSON or not. By default a request114 is considered to include JSON data if the mimetype is115 :mimetype:`application/json` or :mimetype:`application/*+json`.116 117 .. versionadded:: 0.115 unmodified lines123 return True124 return False125 126 def get_json(self, force=False, silent=False, cache=True):126- """Parses the incoming JSON request data and returns it. By default127- this function will return ``None`` if self.is_json would return false,128- but this can be overridden by the ``force`` parameter. If parsing129- fails, the :meth:`on_json_loading_failed` method on the request object130- will be invoked.127+ """Parses the incoming JSON request data and returns it. By default128+ this function will return ``None`` if the request does not use a JSON129+ mimetype like :mimetype:`application/json`. See :meth:`is_json`. This130+ can be overridden by the ``force`` parameter. If parsing fails,131+ the :meth:`on_json_loading_failed` method on the request object will be132+ invoked.133 134 :param force: if set to ``True`` the mimetype is ignored.135 :param silent: if set to ``True`` this method will fail silently134- and return ``None``.136+ and return ``None``.137 :param cache: if set to ``True`` the parsed JSON data is remembered136- on the request.138+ on the request.139 """140 rv = getattr(self, '_cached_json', _missing)141 # We return cached JSON only when the cache is enabled.142 if cache and rv is not _missing:64 unmodified lines