mitsuhiko/flask — pull request #471 by jfinkels (2012-04-01 20:41:22+00:00)
Title: Fix #220: Adds a default JSONEncoder implementation to Flask.json_encoder_class

Fix for issue #220 which adds a default `JSONEncoder` implementation to `Flask.json_encoder_class`, which users can override with their own implementation. Also makes jsonify use `current_app.json_encoder_class` as its encoder class. This is solution 1 as proposed by @jparise.

This solution asks users to subclass `flask.JSONEncoder`, which is now exposed as part of the public API for Flask. `flask.JSONEncoder` simply serializes `datetime` objects to ISO 8601 format strings. It can be changed in the future if some other data type becomes common, but I believe this is a reasonable default.