Skip to content
Browse files

Currently Flask use default ``ensure_ascii=True`` for jsonify.

This patch will remove weird behaviour and add `JSON_ASCII` configuration options.
I also had an audacity to correct mimetype encoding for JSON to 'utf-8' by default.
  • Loading branch information...
1 parent ee3e251 commit c2feddf058d431588862ae4417b36920a5afac1a @bobuk bobuk committed
Showing with 8 additions and 1 deletion.
  1. +5 −0 docs/config.rst
  2. +3 −1 flask/
5 docs/config.rst
@@ -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``
4 flask/
@@ -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):

0 comments on commit c2feddf

Please sign in to comment.
Something went wrong with that request. Please try again.