Skip to main content

jsonify

Serialize the given arguments as JSON, and return a :class:~flask.Response object with the application/json mimetype. A dict or list returned from a view will be converted to a JSON response automatically without needing to call this.

def jsonify(
args: t.Any,
kwargs: t.Any
) - > Response

Serialize the given arguments as JSON, and return a :class:~flask.Response object with the application/json mimetype. A dict or list returned from a view will be converted to a JSON response automatically without needing to call this. This requires an active app context, and calls :meth:app.json.response() < flask.json.provider.JSONProvider.response >. In debug mode, the output is formatted with indentation to make it easier to read. This may also be controlled by the provider. Either positional or keyword arguments can be given, not both. If no arguments are given, None is serialized.

Parameters

NameTypeDescription
argst.AnyA single value to serialize, or multiple values to treat as a list to serialize.
kwargst.AnyTreat as a dict to serialize.

Returns

TypeDescription
ResponseA Flask Response object with the serialized JSON and application/json mimetype.