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.ARRPOP

Focus mode
JSON.ARRPOP - Amazon MemoryDB

Remove and return element at the index from the array. Popping an empty array returns null.

Syntax

JSON.ARRPOP <key> [path [index]]
  • key (required) – key of JSON document type

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

  • index (optional) – position in the array to start popping from.

    • Defaults to -1 if not provided, which means the last element.

    • Negative value means position from the last element.

    • Out of boundary indexes are rounded to their respective array boundaries.

Return

If the path is enhanced syntax:

  • Array of bulk strings, representing popped values at each path.

  • If a value is an empty array, its corresponding return value is null.

  • If a value is not an array, its corresponding return value is null.

If the path is restricted syntax:

  • Bulk string, representing the popped JSON value

  • Null if the array is empty.

  • WRONGTYPE error if the value at the path is not an array.

Examples

Enhanced path syntax:

127.0.0.1:6379> JSON.SET k1 . '[[], ["a"], ["a", "b"]]' OK 127.0.0.1:6379> JSON.ARRPOP k1 $[*] 1) (nil) 2) "\"a\"" 3) "\"b\"" 127.0.0.1:6379> JSON.GET k1 "[[],[],[\"a\"]]"

Restricted path syntax:

127.0.0.1:6379> JSON.SET k1 . '[[], ["a"], ["a", "b"]]' OK 127.0.0.1:6379> JSON.ARRPOP k1 "[\"a\",\"b\"]" 127.0.0.1:6379> JSON.GET k1 "[[],[\"a\"]]" 127.0.0.1:6379> JSON.SET k2 . '[[], ["a"], ["a", "b"]]' OK 127.0.0.1:6379> JSON.ARRPOP k2 . 0 "[]" 127.0.0.1:6379> JSON.GET k2 "[[\"a\"],[\"a\",\"b\"]]"
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.