serializing datetime with flasks tojson filter serializing datetime with flasks tojson filter flask flask

serializing datetime with flasks tojson filter


JSON does not handle datetime objects. Standard practice is to encode them as strings in ISO format. This SO question about JSON provides examples. You will need to register the new JSON encoder filter yourself.


Just to be noted.

As of v0.10 Flask has the ability to specify your own json_encoder.

And Flaskā€™s default JSONEncoder is aware of dates (and few other additional things).