def json_serial(obj):
 if isinstance(obj, datetime):
  return obj.isoformat()
 if isinstance(obj, timedelta):
  return obj.microseconds
 return (('<Object ' + type(obj).__name__) + '>')

def json_serial ( obj ) : if isinstance ( obj , datetime ) : return obj . isoformat ( ) if isinstance ( obj , timedelta ) : return obj . microseconds return ( ( '<Object ' + type ( obj ) . __name__ ) + '>' )
json serializer for objects not serializable by default json code .