diff --git a/CHANGES.rst b/CHANGES.rst index e0e15802..1c0ce74f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -32,7 +32,22 @@ Unreleased ``Flask.aborter_class`` and ``Flask.make_aborter`` can be used to customize this aborter. :issue:`4567` - ``flask.redirect`` will call ``app.redirect``. :issue:`4569` + - ``flask.json`` is an instance of ``JSONProvider``. A different + provider can be set to use a different JSON library. + ``flask.jsonify`` will call ``app.json.response``, other + functions in ``flask.json`` will call corresponding functions in + ``app.json``. :pr:`4688` +- JSON configuration is moved to attributes on the default + ``app.json`` provider. ``JSON_AS_ASCII``, ``JSON_SORT_KEYS``, + ``JSONIFY_MIMETYPE``, and ``JSONIFY_PRETTYPRINT_REGULAR`` are + deprecated. :pr:`4688` +- Setting custom ``json_encoder`` and ``json_decoder`` classes on the + app or a blueprint, and the corresponding ``json.JSONEncoder`` and + ``JSONDecoder`` classes, are deprecated. JSON behavior can now be + overridden using the ``app.json`` provider interface. :pr:`4688` +- ``json.htmlsafe_dumps`` and ``json.htmlsafe_dump`` are deprecated, + the function is built-in to Jinja now. :pr:`4688` - Refactor ``register_error_handler`` to consolidate error checking. Rewrite some error messages to be more consistent. :issue:`4559` - Use Blueprint decorators and functions intended for setup after diff --git a/docs/api.rst b/docs/api.rst index 67772a77..5359b370 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -236,21 +236,15 @@ JSON Support .. module:: flask.json -Flask uses the built-in :mod:`json` module for handling JSON. It will -use the current blueprint's or application's JSON encoder and decoder -for easier customization. By default it handles some extra data types: +Flask uses Python's built-in :mod:`json` module for handling JSON by +default. The JSON implementation can be changed by assigning a different +provider to :attr:`flask.Flask.json_provider_class` or +:attr:`flask.Flask.json`. The functions provided by ``flask.json`` will +use methods on ``app.json`` if an app context is active. -- :class:`datetime.datetime` and :class:`datetime.date` are serialized - to :rfc:`822` strings. This is the same as the HTTP date format. -- :class:`uuid.UUID` is serialized to a string. -- :class:`dataclasses.dataclass` is passed to - :func:`dataclasses.asdict`. -- :class:`~markupsafe.Markup` (or any object with a ``__html__`` - method) will call the ``__html__`` method to get a string. - -Jinja's ``|tojson`` filter is configured to use Flask's :func:`dumps` -function. The filter marks the output with ``|safe`` automatically. Use -the filter to render data inside ``