def json_default(obj):
 if isinstance(obj, datetime):
  if (obj.utcoffset() is not None):
   obj = (obj - obj.utcoffset())
  return {'$dt': obj.isoformat()}
 raise TypeError('Type not serializable')

def json_default ( obj ) : if isinstance ( obj , datetime ) : if ( obj . utcoffset ( ) is not None ) : obj = ( obj - obj . utcoffset ( ) ) return { '$dt' : obj . isoformat ( ) } raise TypeError ( 'Type not serializable' )
json serializer for objects not serializable by default json code .