JSON.STRLEN key [path]

Available in: Redis Stack

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

Reports the length of the JSON String at path in key.

path defaults to root if not provided. Returns null if the key or path do not exist.

Return

[] if the matching JSON value is not a string.

Examples

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