def json_get(obj, member, typ, default=None):
    """Tries to get the passed member from the passed JSON object obj and makes
       sure it is instance of the passed typ.

       If the passed member is not found the default is returned instead.

       If the typ is not matched the exception ValueError is raised.
    """

    if not isinstance(obj, dict):
        raise ValueError('the passed JSON is not a dict')

    value = obj.get(member, default)
    if not isinstance(value, typ):
        raise ValueError(f'{member} is not a {typ.__name__}')

    return value