content/commands/json.mget.md
{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}
Return the values at path from multiple key arguments
{{% warning %}} When cluster mode is enabled, all specified keys must reside on the same hash slot.
When the database has more than one shard, and the specified keys reside in different shards, Redis will not report a CROSSSLOT error (to avoid breaking changes) and the results may be partial.
{{% /warning %}}
is key to parse. Returns null for nonexistent keys.
is JSONPath to specify. Returns null for nonexistent paths.
Create two JSON documents.
{{< highlight bash >}} redis> JSON.SET doc1 $ '{"a":1, "b": 2, "nested": {"a": 3}, "c": null}' OK redis> JSON.SET doc2 $ '{"a":4, "b": 5, "nested": {"a": 6}, "c": null}' OK {{< / highlight >}}
Get values from all arguments in the documents.
{{< highlight bash >}} redis> JSON.MGET doc1 doc2 $..a
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Flexible & Annual</span> <span title="Supported">✅ Free & Fixed</nobr></span> | |
{{< multitabs id="json-mget-return-info" tab1="RESP2" tab2="RESP3" >}}
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the JSON serialization of the value at the corresponding key's path, or null if the key or path doesn't exist.
-tab-sep-
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the JSON serialization of the value at the corresponding key's path, or null if the key or path doesn't exist.
{{< /multitabs >}}
[JSON.SET]({{< relref "commands/json.set/" >}}) | [JSON.GET]({{< relref "commands/json.get/" >}})