def _to_bool(s):
    """
    Given a bool or a string representing a boolean value sent over
    JSON, returns the corresponding bool.
    """
    if s is True or s is False:
        return s
    elif s == 'true':
        return True
    elif s == 'false':
        return False
    else:
        assert False, "Error: '%s' is not bool or JSON boolean" % str(s)
