diff --git a/CHANGELOG.md b/CHANGELOG.md index 1caaabbf1e..d825c009eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,6 +114,7 @@ * Node: Add `JSON.NUMINCRBY` and `JSON.NUMMULTBY` command ([#2555](https://github.com/valkey-io/valkey-glide/pull/2555)) * Core: Add support to Availability Zone Affinity read strategy ([#2539](https://github.com/valkey-io/valkey-glide/pull/2539)) * Core: Fix list of readonly commands ([#2634](https://github.com/valkey-io/valkey-glide/pull/2634), [#2649](https://github.com/valkey-io/valkey-glide/pull/2649)) +* Java: Add transaction commands for JSON module ([#2691](https://github.com/valkey-io/valkey-glide/pull/2691)) * Core: Improve retry logic and update unmaintained dependencies for Rust lint CI ([#2673](https://github.com/valkey-io/valkey-glide/pull/2643)) * Core: Release the read lock while creating connections in `refresh_connections` ([#2630](https://github.com/valkey-io/valkey-glide/issues/2630)) * Core: SlotMap refactor - Added NodesMap, Update the slot map upon MOVED errors ([#2682](https://github.com/valkey-io/valkey-glide/issues/2682)) diff --git a/java/client/src/main/java/glide/api/commands/servermodules/MultiJson.java b/java/client/src/main/java/glide/api/commands/servermodules/MultiJson.java new file mode 100644 index 0000000000..32f19b45c1 --- /dev/null +++ b/java/client/src/main/java/glide/api/commands/servermodules/MultiJson.java @@ -0,0 +1,1205 @@ +/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ +package glide.api.commands.servermodules; + +import static glide.utils.ArgsBuilder.checkTypeOrThrow; +import static glide.utils.ArgsBuilder.newArgsBuilder; + +import glide.api.models.BaseTransaction; +import glide.api.models.Transaction; +import glide.api.models.commands.ConditionalChange; +import glide.api.models.commands.json.JsonArrindexOptions; +import glide.api.models.commands.json.JsonGetOptions; +import lombok.NonNull; + +/** + * Transaction implementation for JSON module. Transactions allow the execution of a group of + * commands in a single step. See {@link Transaction}. + * + * @example + *
{@code + * Transaction transaction = new Transaction(); + * MultiJson.set(transaction, "doc", ".", "{\"a\": 1.0, \"b\": 2}"); + * MultiJson.get(transaction, "doc"); + * Object[] result = client.exec(transaction).get(); + * assert result[0].equals("OK"); // result of MultiJson.set() + * assert result[1].equals("{\"a\": 1.0, \"b\": 2}"); // result of MultiJson.get() + * }+ */ +public class MultiJson { + + private static final String JSON_PREFIX = "JSON."; + private static final String JSON_SET = JSON_PREFIX + "SET"; + private static final String JSON_GET = JSON_PREFIX + "GET"; + private static final String JSON_MGET = JSON_PREFIX + "MGET"; + private static final String JSON_NUMINCRBY = JSON_PREFIX + "NUMINCRBY"; + private static final String JSON_NUMMULTBY = JSON_PREFIX + "NUMMULTBY"; + private static final String JSON_ARRAPPEND = JSON_PREFIX + "ARRAPPEND"; + private static final String JSON_ARRINSERT = JSON_PREFIX + "ARRINSERT"; + private static final String JSON_ARRINDEX = JSON_PREFIX + "ARRINDEX"; + private static final String JSON_ARRLEN = JSON_PREFIX + "ARRLEN"; + private static final String[] JSON_DEBUG_MEMORY = new String[] {JSON_PREFIX + "DEBUG", "MEMORY"}; + private static final String[] JSON_DEBUG_FIELDS = new String[] {JSON_PREFIX + "DEBUG", "FIELDS"}; + private static final String JSON_ARRPOP = JSON_PREFIX + "ARRPOP"; + private static final String JSON_ARRTRIM = JSON_PREFIX + "ARRTRIM"; + private static final String JSON_OBJLEN = JSON_PREFIX + "OBJLEN"; + private static final String JSON_OBJKEYS = JSON_PREFIX + "OBJKEYS"; + private static final String JSON_DEL = JSON_PREFIX + "DEL"; + private static final String JSON_FORGET = JSON_PREFIX + "FORGET"; + private static final String JSON_TOGGLE = JSON_PREFIX + "TOGGLE"; + private static final String JSON_STRAPPEND = JSON_PREFIX + "STRAPPEND"; + private static final String JSON_STRLEN = JSON_PREFIX + "STRLEN"; + private static final String JSON_CLEAR = JSON_PREFIX + "CLEAR"; + private static final String JSON_RESP = JSON_PREFIX + "RESP"; + private static final String JSON_TYPE = JSON_PREFIX + "TYPE"; + + private MultiJson() {} + + /** + * Sets the JSON value at the specified
path
stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param path Represents the path within the JSON document where the value will be set. The key
+ * will be modified only if value
is added as the last child in the specified
+ * path
, or if the specified path
acts as the parent of a new child
+ * being added.
+ * @param value The value to set at the specific path, in JSON formatted string.
+ * @return Command Response - A simple "OK"
response if the value is successfully
+ * set.
+ */
+ public static path
stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param path Represents the path within the JSON document where the value will be set. The key
+ * will be modified only if value
is added as the last child in the specified
+ * path
, or if the specified path
acts as the parent of a new child
+ * being added.
+ * @param value The value to set at the specific path, in JSON formatted string.
+ * @param setCondition Set the value only if the given condition is met (within the key or path).
+ * @return Command Response - A simple "OK"
response if the value is successfully
+ * set. If value isn't set because of setCondition
, returns null
.
+ */
+ public static path
stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @return Command Response - Returns a string representation of the JSON document. If key
+ *
doesn't exist, returns null
.
+ */
+ public static paths
stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param paths List of paths within the JSON document.
+ * @return Command Response -
+ * $
): Returns a stringified JSON list
+ * replies for every possible path, or a string representation of an empty array,
+ * if path doesn't exist. If key
doesn't exist, returns null
+ *
.
+ * $
): Returns a string
+ * representation of the value in paths
. If paths
+ * doesn't exist, an error is raised. If key
doesn't exist, returns
+ * null
.
+ * paths
are a mix of both JSONPath and legacy
+ * path, the command behaves as if all are JSONPath paths.
+ */
+ public static path
stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param options Options for formatting the byte representation of the JSON data. See
+ * JsonGetOptions
.
+ * @return Command Response - Returns a string representation of the JSON document. If key
+ *
doesn't exist, returns null
.
+ */
+ public static path
stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param paths List of paths within the JSON document.
+ * @param options Options for formatting the byte representation of the JSON data. See
+ * JsonGetOptions
.
+ * @return Command Response -
+ * $
): Returns a stringified JSON list
+ * replies for every possible path, or a string representation of an empty array,
+ * if path doesn't exist. If key
doesn't exist, returns null
+ *
.
+ * $
): Returns a string
+ * representation of the value in paths
. If paths
+ * doesn't exist, an error is raised. If key
doesn't exist, returns
+ * null
.
+ * paths
are a mix of both JSONPath and legacy
+ * path, the command behaves as if all are JSONPath paths.
+ */
+ public static path
stored at multiple keys
+ *
.
+ *
+ * @apiNote When using ClusterTransaction, all keys in the transaction must be mapped to the same
+ * slot.
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param keys The keys of the JSON documents.
+ * @param path The path within the JSON documents.
+ * @return Command Response -An array with requested values for each key.
+ * $
): Returns a stringified JSON list
+ * replies for every possible path, or a string representation of an empty array, if
+ * path doesn't exist.
+ * $
): Returns a string
+ * representation of the value in path
. If path
doesn't exist,
+ * the corresponding array element will be null
.
+ * key
doesn't exist, the corresponding array element will be null
+ *
.
+ */
+ public static values
to the JSON array at the specified path
+ * within the JSON document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param path Represents the path
within the JSON document where the values
+ *
will be appended.
+ * @param values The JSON values to be appended to the array."foo"
,
+ * pass "\"foo\""
.
+ * @return Command Response -
+ * path
starts with $
):values
, or null
for JSON values
+ * matching the path that are not an array. If path
does not exist, an
+ * empty array will be returned.
+ * path
doesn't start with $
):values
to the array
+ * at path
. If multiple paths are matched, returns the last updated array.
+ * If the JSON value at path
is not an array or if path
+ * doesn't exist, an error is raised. If key
doesn't exist, an error is
+ * raised.
+ */
+ public static path
within the JSON
+ * document stored at key
, before the given index
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @param index The array index before which values are inserted.
+ * @param values The JSON values to be inserted into the array."foo"
,
+ * pass "\"foo\""
.
+ * @return Command Response -
+ * path
starts with $
):Object[]
with a list of integers for every possible path,
+ * indicating the new length of the array, or null
for JSON values matching
+ * the path that are not an array. If path
does not exist, an empty array
+ * will be returned.
+ * path
doesn't start with $
):path
doesn't
+ * exist or the value at path
is not an array, an error is raised.
+ * key
doesn't exist, an error is raised.
+ */
+ public static scalar
JSON value in the arrays at the
+ * path.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @param scalar The scalar value to search for.
+ * @return Command Response -
+ * path
starts with $
): Returns an array with a
+ * list of integers for every possible path, indicating the index of the matching
+ * element. The value is -1
if not found. If a value is not an array, its
+ * corresponding return value is null
.
+ * $
): Returns an integer
+ * representing the index of matching element, or -1
if not found. If the
+ * value at the path
is not an array, an error is raised.
+ * scalar
JSON value in the arrays at the
+ * path.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @param scalar The scalar value to search for.
+ * @param options The additional options for the command. See JsonArrindexOptions
.
+ * @return Command Response -
+ * path
starts with $
): Returns an array with a
+ * list of integers for every possible path, indicating the index of the matching
+ * element. The value is -1
if not found. If a value is not an array, its
+ * corresponding return value is null
.
+ * $
): Returns an integer
+ * representing the index of matching element, or -1
if not found. If the
+ * value at the path
is not an array, an error is raised.
+ * path
within the JSON document
+ * stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):Object[]
with a list of integers for every possible path,
+ * indicating the length of the array, or null
for JSON values matching the
+ * path that are not an array. If path
does not exist, an empty array will
+ * be returned.
+ * path
doesn't start with $
):path
doesn't
+ * exist or the value at path
is not an array, an error is raised.
+ * key
doesn't exist, returns null
.
+ */
+ public static key
.
+ * path
set to
+ *
+ * "."
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - The array length stored at the root of the document. If document
+ * root is not an array, an error is raised.key
doesn't exist, returns null
.
+ */
+ public static path
within the
+ * JSON document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):Object[]
with a list of numbers for every possible path,
+ * indicating the memory usage. If path
does not exist, an empty array will
+ * be returned.
+ * path
doesn't start with $
):path
doesn't exist, an
+ * error is raised.
+ * key
doesn't exist, returns null
.
+ */
+ public static path
within the
+ * JSON document stored at key
.path
+ * set to ".."
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - The total memory usage in bytes of the entire JSON document.key
doesn't exist, returns null
.
+ * @example
+ * {@code + * Json.set(client, "doc", "$", "[1, 2.3, \"foo\", true, null, {}, [], {\"a\":1, \"b\":2}, [1, 2, 3]]").get(); + * var res = Json.debugMemory(client, "doc").get(); + * assert res == 258L; + * }+ */ + public static
path
within the JSON document stored
+ * at key
.path
starts with $
):Object[]
with a list of numbers for every possible path,
+ * indicating the number of fields. If path
does not exist, an empty array
+ * will be returned.
+ * path
doesn't start with $
):path
doesn't exist, an
+ * error is raised.
+ * key
doesn't exist, returns null
.
+ */
+ public static path
within the JSON document stored
+ * at key
.path
+ * set to ".."
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - The total number of fields in the entire JSON document.key
doesn't exist, returns null
.
+ */
+ public static
+ * key
. Equivalent to {@link #arrpop(BaseTransaction, ArgType, ArgType)} with
+ * path
set to "."
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @return Command Response - Returns a string representing the popped JSON value, or null
+ *
if the array at document root is empty.key
doesn't exist, an
+ * error is raised.
+ */
+ public static path
in the JSON document stored
+ * at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):null
for JSON values matching the path that are not an array
+ * or an empty array.
+ * path
doesn't start with $
):null
if the
+ * array at path
is empty. If multiple paths are matched, the value from
+ * the first matching array that is not empty is returned. If path
doesn't
+ * exist or the value at path
is not an array, an error is raised.
+ * key
doesn't exist, an error is raised.
+ */
+ public static path
in the JSON document stored at
+ * key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param path The path within the JSON document.
+ * @param index The index of the element to pop. Out of boundary indexes are rounded to their
+ * respective array boundaries.
+ * @return Command Response -
+ * path
starts with $
):null
for JSON values matching the path that are not an array
+ * or an empty array.
+ * path
doesn't start with $
):null
if the
+ * array at path
is empty. If multiple paths are matched, the value from
+ * the first matching array that is not empty is returned. If path
doesn't
+ * exist or the value at path
is not an array, an error is raised.
+ * key
doesn't exist, an error is raised.
+ */
+ public static path
within the JSON document stored at key
+ *
so that it becomes a subarray [start
, end
], both inclusive.
+ * start
< 0, it is treated as 0.end
>= size (size of the array), it is treated as size -1.start
>= size or start
> end
, the array is emptied
+ * and 0 is return.path
starts with $
):Object[]
with a list of integers for every possible path,
+ * indicating the new length of the array, or null
for JSON values matching
+ * the path that are not an array. If the array is empty, its corresponding return value
+ * is 0. If path
doesn't exist, an empty array will be return. If an index
+ * argument is out of bounds, an error is raised.
+ * path
doesn't start with $
):path
doesn't exist, or the value at
+ * path
is not an array, an error is raised. If an index argument is out of
+ * bounds, an error is raised.
+ * key
doesn't exist, returns null
.
+ */
+ public static path
by number
+ *
within the JSON document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @param number The number to increment or decrement by.
+ * @return Command Response -
+ * path
starts with $
):path
.null
.
+ * path
doesn't exist, a byte string representation of an empty array
+ * will be returned.
+ * path
doesn't start with $
):path
is not a number or path
doesn't
+ * exist, an error is raised.
+ * key
does not exist, an error is raised.path
by number
within
+ * the JSON document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @param number The number to multiply by.
+ * @return Command Response -
+ * path
starts with $
):path
.null
.
+ * path
doesn't exist, a byte string representation of an empty array
+ * will be returned.
+ * path
doesn't start with $
):path
is not a number or path
doesn't
+ * exist, an error is raised.
+ * key
does not exist, an error is raised.path
+ * within the JSON document stored at key
.path
set to
+ *
+ * "."
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - The object length stored at the root of the document. If document
+ * root is not an object, an error is raised.key
doesn't exist, returns null
.
+ */
+ public static path
+ * within the JSON document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):Object[]
with a list of long integers for every possible
+ * path, indicating the number of key-value pairs for each matching object, or
+ * null
+ *
for JSON values matching the path that are not an object. If path
+ *
does not exist, an empty array will be returned.
+ * path
doesn't start with $
):path
doesn't exist or the value at path
is not an array, an
+ * error is raised.
+ * key
doesn't exist, returns null
.
+ */
+ public static path
within the JSON
+ * document stored at key
.path
set to
+ *
+ * "."
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - The object length stored at the root of the document. If document
+ * root is not an object, an error is raised.key
doesn't exist, returns null
.
+ */
+ public static path
within the JSON
+ * document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):Object[][]
with each nested array containing key names for
+ * each matching object for every possible path, indicating the list of object keys for
+ * each matching object, or null
for JSON values matching the path that are
+ * not an object. If path
does not exist, an empty sub-array will be
+ * returned.
+ * path
doesn't start with $
):path
+ *
doesn't exist or the value at path
is not an array, an error is
+ * raised.
+ * key
doesn't exist, returns null
.
+ */
+ public static key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @return Command Response - The number of elements deleted. 0 if the key does not exist.
+ */
+ public static path
within the JSON document stored at
+ * key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param path Represents the path within the JSON document where the value will be deleted.
+ * @return Command Response - The number of elements deleted. 0 if the key does not exist, or if
+ * the JSON path is invalid or does not exist.
+ */
+ public static key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @return Command Response - The number of elements deleted. 0 if the key does not exist.
+ */
+ public static path
within the JSON document stored at
+ * key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key
of the JSON document.
+ * @param path Represents the path within the JSON document where the value will be deleted.
+ * @return Command Response - The number of elements deleted. 0 if the key does not exist, or if
+ * the JSON path is invalid or does not exist.
+ */
+ public static key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - Returns the toggled boolean value at the root of the document, or
+ * null
for JSON values matching the root that are not boolean. If key
+ *
doesn't exist, returns null
.
+ */
+ public static path
within the JSON document
+ * stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):Boolean[]
with the toggled boolean value for every possible
+ * path, or null
for JSON values matching the path that are not boolean.
+ * path
doesn't start with $
):path
. If path
+ * doesn't exist or the value at path
isn't a boolean, an error is raised.
+ * key
doesn't exist, returns null
.
+ */
+ public static value
to the string stored at the specified path
+ *
within the JSON document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param value The value to append to the string. Must be wrapped with single quotes. For
+ * example, to append "foo", pass '"foo"'.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):value
, or null
for
+ * JSON values matching the path that are not string.key
doesn't exist, an error is raised.
+ * path
doesn't start with $
):value
to the
+ * string at path
.path
is not a string of if path
+ * doesn't exist, an error is raised.key
doesn't exist, an error is raised.
+ * value
to the string stored at the root within the JSON
+ * document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param value The value to append to the string. Must be wrapped with single quotes. For
+ * example, to append "foo", pass '"foo"'.
+ * @return Command Response - Returns the length of the resulting string after appending
+ * value
to the string at the root.key
doesn't exist, an error is raised.
+ */
+ public static path
within
+ * the JSON document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response -
+ * path
starts with $
):null
for JSON values matching the path that
+ * are not string.
+ * path
doesn't start with $
):path
or null
if
+ * key
doesn't exist.path
is not a string of if path
+ * doesn't exist, an error is raised. If key
doesn't exist, null
+ *
is returned.
+ * key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - Returns the length of the JSON value at the root.key
doesn't exist, null
is returned.
+ */
+ public static key
.path
set to
+ *
+ * "."
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - 1
if the document wasn't empty or 0
if it
+ * was.key
doesn't exist, an error is raised.
+ */
+ public static path
within the JSON document stored at
+ * key
.0
, boolean values are set to false
, and
+ * string values are converted to empty strings.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path The path within the JSON document.
+ * @return Command Response - The number of containers cleared.path
doesn't exist, or the value at path
is already cleared
+ * (e.g., an empty array, object, or string), 0 is returned. If key
doesn't
+ * exist, an error is raised.
+ */
+ public static key
. The returning result is in the Valkey
+ * or Redis OSS Serialization Protocol (RESP).
+ *
+ * key
+ * doesn't exist, null
is returned.
+ */
+ public static path
within the JSON document stored at
+ * key
. The returning result is in the Valkey or Redis OSS Serialization Protocol
+ * (RESP).
+ *
+ * path
starts with $
): Returns a list of
+ * replies for every possible path, indicating the RESP form of the JSON value. If
+ * path
doesn't exist, returns an empty list.
+ * path
doesn't starts with $
): Returns a
+ * single reply for the JSON value at the specified path, in its RESP form. If multiple
+ * paths match, the value of the first JSON value match is returned. If path
+ *
doesn't exist, an error is raised.
+ * key
doesn't exist, null
is returned.
+ */
+ public static key
+ *
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @return Command Response - Returns the type of the JSON value at root. If key
+ * doesn't exist,
+ * null
is returned.
+ */
+ public static path
within the JSON
+ * document stored at key
.
+ *
+ * @param transaction The Valkey GLIDE client to execute the command in transaction.
+ * @param key The key of the JSON document.
+ * @param path Represents the path within the JSON document where the type will be retrieved.
+ * @return Command Response -
+ * path
starts with $
): Returns a list of string
+ * replies for every possible path, indicating the type of the JSON value. If `path`
+ * doesn't exist, an empty array will be returned.
+ * path
doesn't starts with $
): Returns the
+ * type of the JSON value at `path`. If multiple paths match, the type of the first JSON
+ * value match is returned. If `path` doesn't exist, null
will be returned.
+ * key
doesn't exist, null
is returned.
+ */
+ public static