- Usage:
-
JSON.STRLEN key [ path ]
- Complexity:
- O(N) where N is the number of string values matched by the path.
- Module:
- valkey-json
- Since module version:
- 1.0.0
- ACL Categories:
- @read, @fast, @json
-
If the path is enhanced syntax:
-
Array reply: Array of integers representing the length of string value at each path.
-
Nil reply: For each path where the value is not a string.
-
Nil reply: If the document key does not exist.
-
-
If the path is restricted syntax:
-
Integer reply: The string's length.
-
Integer reply: If multiple string values are selected, returns the first string's length.
-
Nil reply: If the document key does not exist.
-
-
-
if the value at the path is not a string (only for restricted syntax).
-
if the path does not exist (only for restricted syntax).
-
-
If the path is enhanced syntax:
-
Array reply: Array of integers representing the length of string value at each path.
-
Null reply: For each path where the value is not a string.
-
Null reply: If the document key does not exist.
-
-
If the path is restricted syntax:
-
Integer reply: The string's length.
-
Integer reply: If multiple string values are selected, returns the first string's length.
-
Null reply: If the document key does not exist.
-
-
-
if the value at the path is not a string (only for restricted syntax).
-
if the path does not exist (only for restricted syntax).
-
Get lengths of the JSON string values at the path.
Examples
Enhanced path syntax:
127.0.0.1:6379> JSON.SET k1 $ '{"a":{"a":"a"}, "b":{"a":"a", "b":1}, "c":{"a":"a", "b":"bb"}, "d":{"a":1, "b":"b", "c":3}}'
OK
127.0.0.1:6379> JSON.STRLEN k1 $.a.a
1) (integer) 1
127.0.0.1:6379> JSON.STRLEN k1 $.a.*
1) (integer) 1
127.0.0.1:6379> JSON.STRLEN k1 $.c.*
1) (integer) 1
2) (integer) 2
127.0.0.1:6379> JSON.STRLEN k1 $.c.b
1) (integer) 2
127.0.0.1:6379> JSON.STRLEN k1 $.d.*
1) (nil)
2) (integer) 1
3) (nil)
Restricted path syntax:
127.0.0.1:6379> JSON.SET k1 $ '{"a":{"a":"a"}, "b":{"a":"a", "b":1}, "c":{"a":"a", "b":"bb"}, "d":{"a":1, "b":"b", "c":3}}'
OK
127.0.0.1:6379> JSON.STRLEN k1 .a.a
(integer) 1
127.0.0.1:6379> JSON.STRLEN k1 .a.*
(integer) 1
127.0.0.1:6379> JSON.STRLEN k1 .c.*
(integer) 1
127.0.0.1:6379> JSON.STRLEN k1 .c.b
(integer) 2
127.0.0.1:6379> JSON.STRLEN k1 .d.*
(integer) 1