Skip to content
Myr

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

1 file+12 added−10 removed

modified:flask/wrappers.py+12 added-10 removed
95 unmodified lines
96 return self.url_rule.endpoint.rsplit('.', 1)[0]9798 @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``.103104 The :meth:`get_json` method should be used instead.105 """106 from warnings import warn
2 unmodified lines
109 return self.get_json()110111 @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`.116117 .. versionadded:: 0.11
5 unmodified lines
123 return True124 return False125126 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.133134 :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