def write_values(self, data, filepath=None, filename=None, indent=None, keys_to_write=None):
        name = filename if filename else self.filename
        path = filepath if filepath else self.filepath
        name = self._ends_with(name, ".json")
        path = self._ends_with(path, os.path.sep)
        if not os.path.isfile(path + name):
            try:
                return self.write_file(data, path, name, indent, keys_to_write)
            except EnvironmentError as error:
                self.logger.error("Error while opening or writing to file: {}".format(error))
                raise
            except ValueError:
                raise
        if keys_to_write:
            data_to_write = {}
            for key in keys_to_write:
                data_to_write[key] = data[key]
        else:
            data_to_write = data
        try:
            with open(path + name, 'r') as fil:
                output = json.load(fil)
                self.logger.info("Read contents of {}".format(filename))
                for key in data_to_write:
                    try:
                        output[key] = data_to_write[key]
                    except TypeError as error:
                        self.logger.error(
                            "File contents could not be serialized into a dict. {}".format(error))
                        raise
            self._write_json(path, name + ".temp", "w", output, indent)
            FileUtils.remove_file(name, path)
            FileUtils.rename_file(name + '.temp', name, path)
            return os.path.join(path, name)
        except EnvironmentError as error:
            self.logger.error(
                "Error while writing to, opening or reading the file: {}".format(error))
            raise
        except ValueError as error:
            self.logger.error(
                "File could not be decoded to JSON. It might be empty? {}".format(error))
            try:
                self._write_json(path, name, "w", data_to_write, indent)
                return os.path.join(path, name)
            except EnvironmentError:
                raise