Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

JSON.CLEAR

Focus mode
JSON.CLEAR - Amazon ElastiCache

Clears the arrays or an object at the path.

Syntax

JSON.CLEAR <key> [path]
  • key (required) – A Valkey or Redis OSS key of JSON document type.

  • path (optional) – A JSON path. Defaults to the root if not provided.

Return

  • Integer, the number of containers cleared.

  • Clearing an empty array or object accounts for 1 container cleared.

  • Clearing a non-container value returns 0.

Examples

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 "[]"
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.