Setting JSONResponse charset to 'utf-8'


I would like to globally set the charset of all JSONResponses in my web app to ‘utf-8’.
What is the recommended way to do that?
Is something like

JSONResponse.charset = 'utf-8'

right after the creation of an App instance OK?

A related question: Why is the class variable JSONResponse.charset set to None by default (line 228 in apistar/ despite the fact that the render function is doing .encode(‘utf-8’) (line 239 in apistar/

I’m refering to apistar version 0.5.40.


The proper media type for JSON is specified as “application/json” without any parameters. It’s explicitly a byte wise encoding in one of utf-8, utf-16 or utf-32, with the encoding indentified in the leading byte markers, (rather than a text type that can be encoded in many different representations)