JSON.STRAPPEND

Syntax

  1. JSON.STRAPPEND key [path] value

Time complexity: O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

Append the json-string values to the string at path

Examples

Required arguments

key

is key to modify.

value

is value to append to one or more strings.

JSON.STRAPPEND - 图1About using strings with JSON commands

To specify a string as an array value to append, wrap the quoted string with an additional set of single quotes. Example: '"silver"'. For more detailed use, see Examples.

Optional arguments

path

is JSONPath to specify. Default is root $.

Return value

JSON.STRAPPEND returns an array of integer replies for each path, the string’s new length, or nil, if the matching JSON value is not a string. For more information about replies, see Redis serialization protocol specification.

Examples

  1. 127.0.0.1:6379> JSON.SET doc $ '{"a":"foo", "nested": {"a": "hello"}, "nested2": {"a": 31}}'
  2. OK
  3. 127.0.0.1:6379> JSON.STRAPPEND doc $..a '"baz"'
  4. 1) (integer) 6
  5. 2) (integer) 8
  6. 3) (nil)
  7. 127.0.0.1:6379> JSON.GET doc $
  8. "[{\"a\":\"foobaz\",\"nested\":{\"a\":\"hellobaz\"},\"nested2\":{\"a\":31}}]"

See also

JSON.ARRAPEND | JSON.ARRINSERT