import json


def write_to_json_file(file_path, file_contents):
    """
    Writes the given file_contents to the file_path in JSON format if current
    user's permissions grants to do so.
    :param file_path: Absolute path for the file
    :param file_contents: Contents of the output file
    :return: Output path
    :rtype: str
    :raises: This method raises OSError if it cannot write to file_path.
    """
    with open(file_path, mode='w', encoding='utf-8') as handler:
        json.dump(file_contents, handler)
    return file_path