import json


def update_json(file_path: str, content: dict) -> bool:
    """
    Function to update json file. The "snakypy.json.read" function depends on
    reading a json file.

    >>> from snakypy import helpers
    >>> data = helpers.files.read_json('/tmp/file.json')
    >>> data['Hello'] = 'Olá, Snakypy!'
    >>> helpers.files.update_json('/tmp/file.json', data)
    True

    Args:
        file_path (str): You must receive the full/absolute file path.

        content (dict): You should receive a dictionary with the updated data already.

    Returns:
        [bool]: If everything went well, it will return True.
    """
    try:
        if type(content) is dict:
            with open(file_path, "w") as f:
                json.dump(content, f, indent=2, separators=(",", ": "))
            return True
        return False
    except PermissionError:
        raise PermissionError(
            f"Your user is not allowed to write to this file. {file_path}"
        )
    except Exception as err:
        msg = f">>> Something unexpected happened while updating {file_path}"
        raise Exception(msg, err)