JSON.STRLEN

Syntax

  1. JSON.STRLEN key [path]

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

ACL categories: @json

Report the length of the JSON String at path in key

Examples

Required arguments

key

is key to parse.

Optional arguments

path

is JSONPath to specify. Default is root $, if not provided. Returns null if the key or path do not exist.

Return

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

Examples

  1. dragonfly> JSON.SET doc $ '{"a":"foo", "nested": {"a": "hello"}, "nested2": {"a": 31}}'
  2. OK
  3. dragonfly> JSON.STRLEN doc $..a
  4. 1) (integer) 3
  5. 2) (integer) 5
  6. 3) (nil)

See also

JSON.ARRLEN | JSON.ARRINSERT