Repository: redis/redis-py
File: redis/commands/json/commands.py (Python)

Code before:
        ``decode_keys`` If set to True, the keys of ``obj`` will be decoded
        with utf-8.

        For the purpose of using this within a pipeline, this command is also
        aliased to JSON.SET.

        For more information see `JSON.SET <https://redis.io/commands/json.set>`_.
        """
        if decode_keys:
            obj = decode_dict_keys(obj)

        pieces = [name, str(path), self._encode(obj)]

        # Handle existential modifiers
        if nx and xx:
            raise Exception(
                "nx and xx are mutually exclusive: use one, the "
                "other or neither - but not both"
            )
        elif nx:
            pieces.append("NX")
        elif xx:
            pieces.append("XX")
        return self.execute_command("JSON.SET", *pieces)

    def mset(self, name: str, path: str, obj: JsonType, *items) -> Optional[str]:
        """
        Set the JSON value at key ``name`` under the ``path`` to ``obj``
        for one or more keys.

        ``items`` accepts a list of additional key/path/value to set.

        For the purpose of using this within a pipeline, this command is also
        aliased to JSON.MSET.

        For more information see `JSON.MSET <https://redis.io/commands/json.mset>`_.
        """

        pieces = [name, path, self._encode(obj)]

        for key, path, value in zip(*[iter(items)] * 3):
            pieces.extend([key, path, self._encode(value)])

        return self.execute_command("JSON.MSET", *pieces)

    def merge(
        self,
        name: str,
        path: str,
        obj: JsonType,
        decode_keys: Optional[bool] = False,

Review comment (suggestion):
IMHO the interface shoudl be changed. It's unclear that these are collections of name/path/str objects

Code after:
        ``decode_keys`` If set to True, the keys of ``obj`` will be decoded
        with utf-8.

        For the purpose of using this within a pipeline, this command is also
        aliased to JSON.SET.

        For more information see `JSON.SET <https://redis.io/commands/json.set>`_.
        """
        if decode_keys:
            obj = decode_dict_keys(obj)

        pieces = [name, str(path), self._encode(obj)]

        # Handle existential modifiers
        if nx and xx:
            raise Exception(
                "nx and xx are mutually exclusive: use one, the "
                "other or neither - but not both"
            )
        elif nx:
            pieces.append("NX")
        elif xx:
            pieces.append("XX")
        return self.execute_command("JSON.SET", *pieces)

    def mset(self, triplets: List[Tuple[str, str, JsonType]]) -> Optional[str]:
        """
        Set the JSON value at key ``name`` under the ``path`` to ``obj``
        for one or more keys.

        ``triplets`` is a list of one or more triplets of key, path, value.

        For the purpose of using this within a pipeline, this command is also
        aliased to JSON.MSET.

        For more information see `JSON.MSET <https://redis.io/commands/json.mset>`_.
        """
        pieces = []
        for triplet in triplets:
            pieces.extend([triplet[0], str(triplet[1]), self._encode(triplet[2])])
        return self.execute_command("JSON.MSET", *pieces)

    def merge(
        self,
        name: str,
        path: str,
        obj: JsonType,
        decode_keys: Optional[bool] = False,
    ) -> Optional[str]:
        """
        Sets or updates the JSON value at a path..