<p dir="auto">I created a custom JSON encoder class extended from flask.json.JSONEncoder but it is not called when calling flask.jsonify. Additionally, I removed my custom JSON encoder and confirmed that  flask.json.JSONEncoder isn't called either via a break statement in Pycharm.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from flask import Flask
from flask import jsonify
from flask.json import JSONEncoder

class MyEncoder(JSONEncoder):
    def default(self, obj):
        if hasattr(obj, '__json__'):
            return obj.__json__()
        else:
            try:
                iterable = iter(obj)
            except TypeError:
                pass
            else:
                return list(iterable)

        return JSONEncoder.default(self, obj)


class MyClass(object):
    key = 'a'
    value = 'b'

    def __json__(self):
        return {'key': self.key, 'value': self.value}

app = Flask(__name__)
app.json_encoder = MyEncoder

@app.route('/')
def hello_world():
    return jsonify(MyClass())


if __name__ == '__main__':
    app.run(debug=True)"><pre class="notranslate"><code class="notranslate">from flask import Flask
from flask import jsonify
from flask.json import JSONEncoder

class MyEncoder(JSONEncoder):
    def default(self, obj):
        if hasattr(obj, '__json__'):
            return obj.__json__()
        else:
            try:
                iterable = iter(obj)
            except TypeError:
                pass
            else:
                return list(iterable)

        return JSONEncoder.default(self, obj)


class MyClass(object):
    key = 'a'
    value = 'b'

    def __json__(self):
        return {'key': self.key, 'value': self.value}

app = Flask(__name__)
app.json_encoder = MyEncoder

@app.route('/')
def hello_world():
    return jsonify(MyClass())


if __name__ == '__main__':
    app.run(debug=True)
</code></pre></div>
<p dir="auto">ECMAscript 5 changed behavior of Array literals. That part of the documentation is outdated by now. We should check what browsers are affected by this and update the docs accordingly.</p>