How can I serialize a python list contains datetime.date
objects, to a JSON array of javascript Date
objects? For example:
lst = [datetime.date(2013, 12, 30), datetime.date(2013, 12, 31)]
print serialize(lst)
# should print "[new Date(2013, 12, 30), new Date(2013, 12, 31)]"
I've tried json.dumps
with a custom handler but the handler can only return serializable objects and not the actual JSON syntax.