JSON Response Filtering Fails with Non-ASCII Characters

Bug
from flask import Flask, jsonify
app = Flask(__name__)
DATA = {"message": {"en-us": "Hello World!", "zh-cn": "你好,世界!"}}
@app.route('/hello_ascii')
def hello_ascii():
app.json.ensure_ascii = True
return jsonify(DATA)
@app.route('/hello_no_ascii')
def hello_no_ascii():
app.json.ensure_ascii = False
return jsonify(DATA)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
JSONPath filter: $.message.zh-cn
hello_ascii
before:
{ "message": { "en-us": "Hello World!", "zh-cn": "你好,世界!" } }after:
[ "你好,世界!" ]hello_no_ascii
before:
{ "message": { "en-us": "Hello World!", "zh-cn": "你好,世界!" } }after:
[ "菴�螂ス�御ク也阜��" ]Windows2025.5.5
Oh, that’s not good. Thanks reporting this!
Reproduced.
It is caused by the charset used when filtering json.
The first step of filter is loading the content from reponse body with a specificed decoder.
When
json.ensure_ascii = True, the reponse bodyare escaped with\uXXXXsequences. So the decoder works. Butapp.json.ensure_ascii = Falsefails it.The root reason is that the loading decoder does’t support other charset just
SHIFT_JIS.try fix by
https://github.com/mountain-loop/yaak/pull/251
Same or related to
https://feedback.yaak.app/p/json-response-filtering-fails-with-non-ascii-characters ?
https://yaak.app/blog/2025.6.0-beta.2
https://yaak.app/blog/2025.6.0
Thanks for the update 🎉. It is working for me now.