def asbool(val, default=None):
    """Convert a string representation of boolean value to boolean type."""
    try:
        if val and isinstance(val, str):
            v = True if val.lower() == 'true' else False
        else:
            v = bool(val)
    except:
        v = default
    return v
