JSON.TYPE

Usage:
JSON.TYPE key [ path ]
Complexity:
O(N) where N is the number of json values matched by the path.
Module:
valkey-json
Since module version:
1.0.0
ACL Categories:
@read, @fast, @json

Report type of the values at the given path.

Examples

Enhanced path syntax:

127.0.0.1:6379> JSON.SET k1 . '[1, 2.3, "foo", true, null, {}, []]'
OK
127.0.0.1:6379> JSON.TYPE k1 $[*]
1) integer
2) number
3) string
4) boolean
5) null
6) object
7) array

Restricted path syntax:

127.0.0.1:6379> JSON.SET k1 . '{"firstName":"John","lastName":"Smith","age":27,"weight":135.25,"isAlive":true,"address":{"street":"21 2nd Street","city":"New York","state":"NY","zipcode":"10021-3100"},"phoneNumbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}],"children":[],"spouse":null}'
OK
127.0.0.1:6379> JSON.TYPE k1
object
127.0.0.1:6379> JSON.TYPE k1 .children
array
127.0.0.1:6379> JSON.TYPE k1 .firstName
string
127.0.0.1:6379> JSON.TYPE k1 .age
integer
127.0.0.1:6379> JSON.TYPE k1 .weight
number
127.0.0.1:6379> JSON.TYPE k1 .isAlive
boolean
127.0.0.1:6379> JSON.TYPE k1 .spouse
null

RESP2 Reply

  • If the path is enhanced syntax:

    • Array reply: Array of strings representing type of the value at each path (one of: 'nil', 'boolean', 'string', 'number', 'integer', 'object', 'array').

    • Nil reply: For each path that does not exist.

    • Array reply: Empty array if the document key does not exist.

  • If the path is restricted syntax:

RESP3 Reply

  • If the path is enhanced syntax:

    • Array reply: Array of strings representing type of the value at each path (one of: 'null', 'boolean', 'string', 'number', 'integer', 'object', 'array').

    • Null reply: For each path that does not exist.

    • Array reply: Empty array if the document key does not exist.

  • If the path is restricted syntax: