JSON.MGET
JSON.MGET key [key ...] path
- Available in:
- Redis Stack / JSON 1.0.0
- Time complexity:
- O(M*N) when path is evaluated to a single value where M is the number of keys and N is the size of the value, O(N1+N2+...+Nm) when path is evaluated to multiple values where m is the number of keys and Ni is the size of the i-th key
Return the values at path
from multiple key
arguments
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.
Required arguments
key
is key to parse. Returns null
for nonexistent keys.
Optional arguments
path
is JSONPath to specify. Returns null
for nonexistent paths.
Return
JSON.MGET returns an array of bulk string replies specified as the JSON serialization of the value at each key's path. For more information about replies, see Redis serialization protocol specification.
Examples
Return the values at path
from multiple key
arguments
Create two JSON documents.
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
Get values from all arguments in the documents.
redis> JSON.MGET doc1 doc2 $..a
1) "[1,3]"
2) "[4,6]"