Browse Source

Merge pull request #1703 from jeffwidman/master

Cleanup jsonify() function
pull/1711/head
David Lord 9 years ago
parent
commit
7df543d5dc
  1. 2
      CHANGES
  2. 8
      flask/json.py

2
CHANGES

@ -10,7 +10,7 @@ Version 1.0
- Added support to serializing top-level arrays to :func:`flask.jsonify`. This
introduces a security risk in ancient browsers. See
:ref:`json_security` for details.
:ref:`json-security` for details.
- Added before_render_template signal.
- Added `**kwargs` to :meth:`flask.Test.test_client` to support passing
additional keyword arguments to the constructor of

8
flask/json.py

@ -237,7 +237,7 @@ def jsonify(*args, **kwargs):
.. versionchanged:: 1.0
Added support for serializing top-level arrays. This introduces a
security risk in ancient browsers. See :ref:`json_security` for details.
security risk in ancient browsers. See :ref:`json-security` for details.
This function's response will be pretty printed if it was not requested
with ``X-Requested-With: XMLHttpRequest`` to simplify debugging unless
@ -262,10 +262,8 @@ def jsonify(*args, **kwargs):
)
elif len(args) == 1: # single args are passed directly to dumps()
data = args[0]
elif args: # convert multiple args into an array
data = list(args)
else: # convert kwargs to a dict
data = dict(kwargs)
else:
data = args or kwargs
# Note that we add '\n' to end of response
# (see https://github.com/mitsuhiko/flask/pull/1262)

Loading…
Cancel
Save