Method: flask.json.jsonify
Calls: 23, Exceptions: 1, Paths: 1Back
Path 1: 23 calls (1.0)
tuple (6) () (5) ('dummy',) (1) ('fake args',) (1) (0,) (1) (-1,) (1) (1,) (1) (23,) (1) (3.14,) (1) ('s',) (1)
{} (17) dict (5) {'kwargs': 'fake'} (1)
Response (22) None (1)
TypeError (1)
1def jsonify(*args: t.Any, **kwargs: t.Any) -> Response:
2 """Serialize the given arguments as JSON, and return a
3 :class:`~flask.Response` object with the ``application/json``
4 mimetype. A dict or list returned from a view will be converted to a
5 JSON response automatically without needing to call this.
6
7 This requires an active request or application context, and calls
8 :meth:`app.json.response() <flask.json.provider.JSONProvider.response>`.
9
10 In debug mode, the output is formatted with indentation to make it
11 easier to read. This may also be controlled by the provider.
12
13 Either positional or keyword arguments can be given, not both.
14 If no arguments are given, ``None`` is serialized.
15
16 :param args: A single value to serialize, or multiple values to
17 treat as a list to serialize.
18 :param kwargs: Treat as a dict to serialize.
19
20 .. versionchanged:: 2.2
21 Calls ``current_app.json.response``, allowing an app to override
22 the behavior.
23
24 .. versionchanged:: 2.0.2
25 :class:`decimal.Decimal` is supported by converting to a string.
26
27 .. versionchanged:: 0.11
28 Added support for serializing top-level arrays. This was a
29 security risk in ancient browsers. See :ref:`security-json`.
30
31 .. versionadded:: 0.2
32 """
33 return current_app.json.response(*args, **kwargs)