---
acl_categories:
- '@json'
- '@read'
- '@slow'
arguments:
- name: key
type: key
- name: path
optional: true
type: string
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
complexity: O(N) when path is evaluated to a single value, where N is the number of
keys in the object, O(N) when path is evaluated to multiple values, where N is the
size of the key
description: Returns the JSON keys of the object at path
group: json
hidden: false
linkTitle: JSON.OBJKEYS
module: JSON
railroad_diagram: /images/railroad/json.objkeys.svg
since: 1.0.0
stack_path: docs/data-types/json
summary: Returns the JSON keys of the object at path
syntax_fmt: JSON.OBJKEYS key [path]
title: JSON.OBJKEYS
---
Return the keys in the object that's referenced by `path`
[Examples](#examples)
## Required arguments
key
is key to parse. Returns `null` for nonexistent keys.
## Optional arguments
path
is JSONPath to specify. Default is root `$`. Returns `null` for nonexistant path.
## Examples
{{< highlight bash >}}
redis> JSON.SET doc $ '{"a":[3], "nested": {"a": {"b":2, "c": 1}}}'
OK
redis> JSON.OBJKEYS doc $..a
1) (nil)
2) 1) "b"
2) "c"
{{< / highlight >}}
## Redis Software and Redis Cloud compatibility
| Redis
Software | Redis
Cloud | Notes |
|:----------------------|:-----------------|:------|
| ✅ Supported
| ✅ Flexible & Annual
✅ Free & Fixed | |
## Return information
{{< multitabs id="json-objkeys-return-info"
tab1="RESP2"
tab2="RESP3" >}}
With `$`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [array replies]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}), where each nested array contains the key names in the object, or `null` if the matching value is not an object.
With `.`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing the key names in the object, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an object.
-tab-sep-
With `$`-based path argument (default): [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [array replies]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}), where each nested array contains the key names in the object, or `null` if the matching value is not an object.
With `.`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing the key names in the object, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an object.
{{< /multitabs >}}
## See also
[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})
## Related topics
* [RedisJSON]({{< relref "/develop/data-types/json/" >}})
* [Index and search JSON documents]({{< relref "/develop/ai/search-and-query/indexing/" >}})