Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add `JSON_ASCII` option to remove unneeded decoding on client side #535

wants to merge 1 commit into
Jump to file or symbol
Failed to load files and symbols.
+8 −1
@@ -142,6 +142,11 @@ The following configuration values are used internally by Flask:
``PREFERRED_URL_SCHEME`` The URL scheme that should be used for
URL generation if no URL scheme is
available. This defaults to ``http``.
+``JSON_ASCII`` By default Flask serialize object to
+ ascii-encoded JSON. If this is set to
+ ``False`` Flask will not encode to ascii
+ and output strings as-is, in system
+ encoding (i.e. in UTF-8).
================================= =========================================
.. admonition:: More on ``SERVER_NAME``
@@ -195,7 +195,9 @@ def get_current_user():
if __debug__:
return current_app.response_class(json.dumps(dict(*args, **kwargs),
- indent=None if request.is_xhr else 2), mimetype='application/json')
+ indent=None if request.is_xhr else 2,
+ ensure_ascii=current_app.config.get('JSON_ASCII', True)),
+ mimetype='application/json; charset=utf-8')
def make_response(*args):