class JSONProvider: (source)
Known subclasses: flask.json.provider.DefaultJSONProvider
A standard set of JSON operations for an application. Subclasses of this can be used to customize JSON behavior or use different JSON libraries. To implement a provider for a specific library, subclass this base class and implement at least :meth:`dumps` and :meth:`loads`. All other methods have default implementations. To use a different provider, either subclass ``Flask`` and set :attr:`~flask.Flask.json_provider_class` to a provider class, or set :attr:`app.json <flask.Flask.json>` to an instance of the class. :param app: An application instance. This will be stored as a :class:`weakref.proxy` on the :attr:`_app` attribute. .. versionadded:: 2.2
Method | __init__ |
Undocumented |
Method | dump |
Serialize data as JSON and write to a file. |
Method | dumps |
Serialize data as JSON. |
Method | load |
Deserialize data as JSON read from a file. |
Method | loads |
Deserialize data as JSON. |
Method | response |
Serialize the given arguments as JSON, and return a :class:`~flask.Response` object with the ``application/json`` mimetype. |
Method | _prepare |
Undocumented |
Instance Variable | _app |
Undocumented |
Serialize data as JSON and write to a file. :param obj: The data to serialize. :param fp: A file opened for writing text. Should use the UTF-8 encoding to be valid JSON. :param kwargs: May be passed to the underlying JSON library.
flask.json.provider.DefaultJSONProvider
Serialize data as JSON. :param obj: The data to serialize. :param kwargs: May be passed to the underlying JSON library.
Deserialize data as JSON read from a file. :param fp: A file opened for reading text or UTF-8 bytes. :param kwargs: May be passed to the underlying JSON library.
flask.json.provider.DefaultJSONProvider
Deserialize data as JSON. :param s: Text or UTF-8 bytes. :param kwargs: May be passed to the underlying JSON library.
flask.json.provider.DefaultJSONProvider
Serialize the given arguments as JSON, and return a :class:`~flask.Response` object with the ``application/json`` mimetype. The :func:`~flask.json.jsonify` function calls this method for the current application. Either positional or keyword arguments can be given, not both. If no arguments are given, ``None`` is serialized. :param args: A single value to serialize, or multiple values to treat as a list to serialize. :param kwargs: Treat as a dict to serialize.