Python 2.6 json & encoding of datetime.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Wilson

    Python 2.6 json & encoding of datetime.

    Hi there,

    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.aspxwhic h 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?

    Thanks,


    David.
Working...