File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Version 1.0
10
10
11
11
- Added support to serializing top-level arrays to :func:`flask.jsonify`. This
12
12
introduces a security risk in ancient browsers. See
13
- :ref:`json_security ` for details.
13
+ :ref:`json-security ` for details.
14
14
- Added before_render_template signal.
15
15
- Added `**kwargs` to :meth:`flask.Test.test_client` to support passing
16
16
additional keyword arguments to the constructor of
Original file line number Diff line number Diff line change @@ -211,9 +211,9 @@ def jsonify(*args, **kwargs):
211
211
212
212
1. Single argument: Passed straight through to :func:`dumps`.
213
213
2. Multiple arguments: Converted to an array before being passed to
214
- :func:`dumps`.
214
+ :func:`dumps`.
215
215
3. Multiple keyword arguments: Converted to a dict before being passed to
216
- :func:`dumps`.
216
+ :func:`dumps`.
217
217
4. Both args and kwargs: Behavior undefined and will throw an exception.
218
218
219
219
Example usage::
@@ -237,7 +237,7 @@ def get_current_user():
237
237
238
238
.. versionchanged:: 1.0
239
239
Added support for serializing top-level arrays. This introduces a
240
- security risk in ancient browsers. See :ref:`json_security ` for details.
240
+ security risk in ancient browsers. See :ref:`json-security ` for details.
241
241
242
242
This function's response will be pretty printed if it was not requested
243
243
with ``X-Requested-With: XMLHttpRequest`` to simplify debugging unless
@@ -260,12 +260,10 @@ def get_current_user():
260
260
raise TypeError (
261
261
"jsonify() behavior undefined when passed both args and kwargs"
262
262
)
263
- elif len (args ) == 1 : # single args are passed directly to dumps()
263
+ elif len (args ) == 1 : # single args are passed directly to dumps()
264
264
data = args [0 ]
265
- elif args : # convert multiple args into an array
266
- data = list (args )
267
- else : # convert kwargs to a dict
268
- data = dict (kwargs )
265
+ else :
266
+ data = args or kwargs
269
267
270
268
# Note that we add '\n' to end of response
271
269
# (see https://github.com/mitsuhiko/flask/pull/1262)
You can’t perform that action at this time.
0 commit comments