JSON.CLEAR - ElastiCache 适用于 Redis 的 Amazon
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

JSON.CLEAR

清除路径中的数组或对象。

语法

JSON.CLEAR <key> [path]
  • key(必需)– JSON 文档类型的 Redis 键。

  • path(可选)– 一个 JSON 路径。如果未提供,则默认为根目录。

Return

  • 整数,已清除的容器数量。

  • 清除空数组或对象会导致清除 1 个容器。

  • 清除非容器值会返回 0。

示例

127.0.0.1:6379> JSON.SET k1 . '[[], [0], [0,1], [0,1,2], 1, true, null, "d"]' OK 127.0.0.1:6379> JSON.CLEAR k1 $[*] (integer) 7 127.0.0.1:6379> JSON.CLEAR k1 $[*] (integer) 4 127.0.0.1:6379> JSON.SET k2 . '{"children": ["John", "Jack", "Tom", "Bob", "Mike"]}' OK 127.0.0.1:6379> JSON.CLEAR k2 .children (integer) 1 127.0.0.1:6379> JSON.GET k2 .children "[]"