JSON.TYPE

JSON.TYPE key [path]
Available in:
Redis Open Source / JSON 1.0.0
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, @read, @slow,
Compatibility:
Redis Software and Redis Cloud compatibility

Report the type of JSON value at path

The returned type is one of the following strings:

Type Description
null A JSON null value.
boolean A JSON true or false value.
integer A number with no fractional part.
number A number with a fractional part (a floating-point value). 1
string A JSON string value.
object A JSON object (a collection of key-value pairs).
array A JSON array (an ordered list of values).
  1. A floating-point homogeneous array (FPHA) stored with the JSON.SET FPHA argument still reports as array, and its elements report as number. The FP type (FP16, BF16, FP32, or FP64) is an internal storage representation and is not exposed by JSON.TYPE.

Examples

Required arguments

key

is key to parse.

Optional arguments

path

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

Examples

redis> JSON.SET doc $ '{"a":2, "nested": {"a": true}, "foo": "bar"}'
OK
redis> JSON.TYPE doc $..foo
1) "string"
redis> JSON.TYPE doc $..a
1) "integer"
2) "boolean"
redis> JSON.TYPE doc $..dummy
(empty array)

Redis Software and Redis Cloud compatibility

Redis
Software
Redis
Cloud
Notes
✅ Supported
✅ Flexible & Annual
✅ Free & Fixed

Return information

With $-based path argument: Array reply of bulk string replies, where each element is the type of the matching value.

With .-based path argument: Bulk string reply representing the type of the matching value.

See also

JSON.SET | JSON.ARRLEN

RATE THIS PAGE
Back to top ↑