Skip to content
Myr

Merge pull request #2397 from davidism/request-json

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Un-deprecate Request.json

authored by David Lord · committed by GitHub · parents 1172728, 5bc0d15 · Browse files · 3 files+3 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+3 added−34 removed

  • tests:+0 added−26 removed
  • other:+3 added−8 removed

3 files+3 added−34 removed

modified:flask/wrappers.py-8 removed
6 unmodified lines
78 :copyright: (c) 2015 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""11from warnings import warn1211from werkzeug.exceptions import BadRequest12from werkzeug.wrappers import Request as RequestBase, Response as ResponseBase1314from flask import json
26 unmodified lines
41 def json(self):42 """This will contain the parsed JSON data if the mimetype indicates43 JSON (:mimetype:`application/json`, see :meth:`is_json`), otherwise it44 will be ``None``.4748 .. deprecated:: 1.049 Use :meth:`get_json` instead.45 """51 warn(DeprecationWarning(52 "'json' is deprecated. Use 'get_json()' instead."53 ), stacklevel=2)46 return self.get_json()4748 def _get_data_for_json(self, cache):49 return self.get_data(cache=cache)
141 unmodified lines
deleted:tests/test_deprecations.py-26 removed
1# -*- coding: utf-8 -*-2"""3 tests.deprecations4 ~~~~~~~~~~~~~~~~~~56 Tests deprecation support. Not used currently.78 :copyright: (c) 2015 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""1112import flask131415class TestRequestDeprecation(object):16 def test_request_json(self, recwarn, app, client):17 """Request.json is deprecated"""1819 @app.route('/', methods=['POST'])20 def index():21 assert flask.request.json == {'spam': 42}22 print(flask.request.json)23 return 'OK'2425 client.post('/', data='{"spam": 42}', content_type='application/json')26 recwarn.pop(DeprecationWarning)
modified:CHANGES+3 added
94 unmodified lines
95 instead.96 - ``Flask.static_path`` - use ``Flask.static_url_path`` instead.97 - ``Request.module`` - use ``Request.blueprint`` instead.9899- The ``request.json`` property is no longer deprecated. (`#1421`_)100101.. _#1421: https://github.com/pallets/flask/issues/1421102.. _#1489: https://github.com/pallets/flask/pull/1489103.. _#1621: https://github.com/pallets/flask/pull/1621104.. _#1898: https://github.com/pallets/flask/pull/1898105.. _#1936: https://github.com/pallets/flask/pull/1936
642 unmodified lines