Python 2.6 json & encoding of datetime.
dw at botanicus.net
Sat Oct 11 02:39:33 CEST 2008
I've been playing with Python's new json library, and found myself
facing a seemingly simple problem: encoding of datetime objects. Some
'jsonlib' that I was using previously was unable to do this, and the
new built-in json module shares the same limitation.
A bit of googling around brought me to <http://www.west-wind.com/
WebLog/posts/214731.aspx> which seems to suggest there is no
standardised way of doing it. Indeed, reading the rather sparse JSON
RFC makes no mention of it.
It appears my only possibility is writing little helper functions to
convert my datetimes to/from ISO8601 strings or UNIX timestamps, but
this just feels wrong. Suggestions?
More information about the Python-list