#NEWLINE# def squash_dates( obj ) : #NEWLINE# #INDENT# 'squash datetime objects into ISO8601 strings' #NEWLINE# if isinstance ( obj , dict ) : #NEWLINE# #INDENT# obj = dict ( obj ) #NEWLINE# for ( k , v ) in iteritems ( obj ) : #NEWLINE# #INDENT# obj [ k ] = squash_dates ( v ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , ( list , tuple ) ) : #NEWLINE# #INDENT# obj = [ squash_dates ( o ) for o in obj ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , datetime ) : #NEWLINE# #INDENT# obj = obj . isoformat ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return obj