Package glide.api.commands.servermodules
Class Json
- java.lang.Object
-
- glide.api.commands.servermodules.Json
-
public class Json extends java.lang.ObjectModule for JSON commands.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.CompletableFuture<java.lang.Object>arrappend(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, @NonNull GlideString[] values)Appends one or morevaluesto the JSON array at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrappend(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, @NonNull java.lang.String[] values)Appends one or morevaluesto the JSON array at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrindex(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, @NonNull GlideString scalar)Searches for the first occurrence of ascalarJSON value in the arrays at the path.static java.util.concurrent.CompletableFuture<java.lang.Object>arrindex(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, @NonNull GlideString scalar, @NonNull JsonArrindexOptions options)Searches for the first occurrence of ascalarJSON value in the arrays at the path.static java.util.concurrent.CompletableFuture<java.lang.Object>arrindex(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, @NonNull java.lang.String scalar)Searches for the first occurrence of ascalarJSON value in the arrays at the path.static java.util.concurrent.CompletableFuture<java.lang.Object>arrindex(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, @NonNull java.lang.String scalar, @NonNull JsonArrindexOptions options)Searches for the first occurrence of ascalarJSON value in the arrays at the path.static java.util.concurrent.CompletableFuture<java.lang.Object>arrinsert(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, int index, @NonNull GlideString[] values)Inserts one or more values into the array at the specifiedpathwithin the JSON document stored atkey, before the givenindex.static java.util.concurrent.CompletableFuture<java.lang.Object>arrinsert(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, int index, @NonNull java.lang.String[] values)Inserts one or more values into the array at the specifiedpathwithin the JSON document stored atkey, before the givenindex.static java.util.concurrent.CompletableFuture<java.lang.Long>arrlen(@NonNull BaseClient client, @NonNull GlideString key)Retrieves the length of the array at the root of the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrlen(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Retrieves the length of the array at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>arrlen(@NonNull BaseClient client, @NonNull java.lang.String key)Retrieves the length of the array at the root of the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrlen(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Retrieves the length of the array at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<GlideString>arrpop(@NonNull BaseClient client, @NonNull GlideString key)Pops the last element from the array located in the root of the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrpop(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Pops the last element from the array located atpathin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrpop(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, long index)Pops an element from the array located atpathin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>arrpop(@NonNull BaseClient client, @NonNull java.lang.String key)Pops the last element from the array stored in the root of the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrpop(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Pops the last element from the array located atpathin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrpop(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, long index)Pops an element from the array located atpathin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>arrtrim(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, int start, int end)Trims an array at the specifiedpathwithin the JSON document stored atkeyso that it becomes a subarray [start,end], both inclusive.static java.util.concurrent.CompletableFuture<java.lang.Object>arrtrim(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, int start, int end)Trims an array at the specifiedpathwithin the JSON document stored atkeyso that it becomes a subarray [start,end], both inclusive.static java.util.concurrent.CompletableFuture<java.lang.Long>clear(@NonNull BaseClient client, @NonNull GlideString key)Clears an array and an object at the root of the JSON document stored atkey.
Equivalent toclear(BaseClient, GlideString, GlideString)withpathset to".".static java.util.concurrent.CompletableFuture<java.lang.Long>clear(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Clears arrays and objects at the specifiedpathwithin the JSON document stored atkey.
Numeric values are set to0, boolean values are set tofalse, and string values are converted to empty strings.static java.util.concurrent.CompletableFuture<java.lang.Long>clear(@NonNull BaseClient client, @NonNull java.lang.String key)Clears an array and an object at the root of the JSON document stored atkey.
Equivalent toclear(BaseClient, String, String)withpathset to".".static java.util.concurrent.CompletableFuture<java.lang.Long>clear(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Clears arrays and objects at the specifiedpathwithin the JSON document stored atkey.
Numeric values are set to0, boolean values are set tofalse, and string values are converted to empty strings.static java.util.concurrent.CompletableFuture<java.lang.Long>debugFields(@NonNull BaseClient client, @NonNull GlideString key)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field.static java.util.concurrent.CompletableFuture<java.lang.Object>debugFields(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field.static java.util.concurrent.CompletableFuture<java.lang.Long>debugFields(@NonNull BaseClient client, @NonNull java.lang.String key)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field.static java.util.concurrent.CompletableFuture<java.lang.Object>debugFields(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field.static java.util.concurrent.CompletableFuture<java.lang.Long>debugMemory(@NonNull BaseClient client, @NonNull GlideString key)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.
Equivalent todebugMemory(BaseClient, GlideString, GlideString)withpathset togs("..").static java.util.concurrent.CompletableFuture<java.lang.Object>debugMemory(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>debugMemory(@NonNull BaseClient client, @NonNull java.lang.String key)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.
Equivalent todebugMemory(BaseClient, String, String)withpathset to"..".static java.util.concurrent.CompletableFuture<java.lang.Object>debugMemory(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>del(@NonNull BaseClient client, @NonNull GlideString key)Deletes the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>del(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>del(@NonNull BaseClient client, @NonNull java.lang.String key)Deletes the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>del(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>forget(@NonNull BaseClient client, @NonNull GlideString key)Deletes the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>forget(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>forget(@NonNull BaseClient client, @NonNull java.lang.String key)Deletes the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>forget(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<GlideString>get(@NonNull BaseClient client, @NonNull GlideString key)Retrieves the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<GlideString>get(@NonNull BaseClient client, @NonNull GlideString key, @NonNull JsonGetOptionsBinary options)Retrieves the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<GlideString>get(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString[] paths)Retrieves the JSON value at the specifiedpathsstored atkey.static java.util.concurrent.CompletableFuture<GlideString>get(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString[] paths, @NonNull JsonGetOptionsBinary options)Retrieves the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>get(@NonNull BaseClient client, @NonNull java.lang.String key)Retrieves the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>get(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull JsonGetOptions options)Retrieves the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>get(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String[] paths)Retrieves the JSON value at the specifiedpathsstored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>get(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String[] paths, @NonNull JsonGetOptions options)Retrieves the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<GlideString[]>mget(@NonNull BaseClient client, @NonNull GlideString[] keys, @NonNull GlideString path)Retrieves the JSON values at the specifiedpathstored at multiplekeys.static java.util.concurrent.CompletableFuture<java.lang.String[]>mget(@NonNull BaseClient client, @NonNull java.lang.String[] keys, @NonNull java.lang.String path)Retrieves the JSON values at the specifiedpathstored at multiplekeys.static java.util.concurrent.CompletableFuture<GlideString>numincrby(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, java.lang.Number number)Increments or decrements the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>numincrby(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, java.lang.Number number)Increments or decrements the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<GlideString>nummultby(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, java.lang.Number number)Multiplies the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>nummultby(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, java.lang.Number number)Multiplies the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object[]>objkeys(@NonNull BaseClient client, @NonNull GlideString key)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjkeys(BaseClient, GlideString, GlideString)withpathset togs(".").static java.util.concurrent.CompletableFuture<java.lang.Object[]>objkeys(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object[]>objkeys(@NonNull BaseClient client, @NonNull java.lang.String key)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjkeys(BaseClient, String, String)withpathset to".".static java.util.concurrent.CompletableFuture<java.lang.Object[]>objkeys(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>objlen(@NonNull BaseClient client, @NonNull GlideString key)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjlen(BaseClient, GlideString, GlideString)withpathset togs(".").static java.util.concurrent.CompletableFuture<java.lang.Object>objlen(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>objlen(@NonNull BaseClient client, @NonNull java.lang.String key)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjlen(BaseClient, String, String)withpathset to".".static java.util.concurrent.CompletableFuture<java.lang.Object>objlen(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>resp(@NonNull BaseClient client, @NonNull GlideString key)Retrieves the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>resp(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Retrieve the JSON value at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>resp(@NonNull BaseClient client, @NonNull java.lang.String key)Retrieves the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>resp(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Retrieve the JSON value at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>set(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, @NonNull GlideString value)Sets the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>set(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path, @NonNull GlideString value, @NonNull ConditionalChange setCondition)Sets the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>set(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, @NonNull java.lang.String value)Sets the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<java.lang.String>set(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path, @NonNull java.lang.String value, @NonNull ConditionalChange setCondition)Sets the JSON value at the specifiedpathstored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>strappend(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString value)Appends the specifiedvalueto the string stored at the root within the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>strappend(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString value, @NonNull GlideString path)Appends the specifiedvalueto the string stored at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>strappend(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String value)Appends the specifiedvalueto the string stored at the root within the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>strappend(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String value, @NonNull java.lang.String path)Appends the specifiedvalueto the string stored at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>strlen(@NonNull BaseClient client, @NonNull GlideString key)Returns the length of the JSON string value stored at the root within the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>strlen(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Returns the length of the JSON string value stored at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Long>strlen(@NonNull BaseClient client, @NonNull java.lang.String key)Returns the length of the JSON string value stored at the root within the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>strlen(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Returns the length of the JSON string value stored at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Boolean>toggle(@NonNull BaseClient client, @NonNull GlideString key)Toggles a Boolean value stored at the root within the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>toggle(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Toggles a Boolean value stored at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Boolean>toggle(@NonNull BaseClient client, @NonNull java.lang.String key)Toggles a Boolean value stored at the root within the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>toggle(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Toggles a Boolean value stored at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>type(@NonNull BaseClient client, @NonNull GlideString key)Retrieves the type of the JSON value at the root of the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>type(@NonNull BaseClient client, @NonNull GlideString key, @NonNull GlideString path)Retrieves the type of the JSON value at the specifiedpathwithin the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>type(@NonNull BaseClient client, @NonNull java.lang.String key)Retrieves the type of the JSON value at the root of the JSON document stored atkey.static java.util.concurrent.CompletableFuture<java.lang.Object>type(@NonNull BaseClient client, @NonNull java.lang.String key, @NonNull java.lang.String path)Retrieves the type of the JSON value at the specifiedpathwithin the JSON document stored atkey.
-
-
-
Method Detail
-
set
public static java.util.concurrent.CompletableFuture<java.lang.String> set(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, @NonNull @NonNull java.lang.String value)Sets the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be set. The key will be modified only ifvalueis added as the last child in the specifiedpath, or if the specifiedpathacts as the parent of a new child being added.value- The value to set at the specific path, in JSON formatted string.- Returns:
- A simple
"OK"response if the value is successfully set. - Example:
String value = Json.set(client, "doc", ".", "{\"a\": 1.0, \"b\": 2}").get(); assert value.equals("OK");
-
set
public static java.util.concurrent.CompletableFuture<java.lang.String> set(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, @NonNull @NonNull GlideString value)Sets the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be set. The key will be modified only ifvalueis added as the last child in the specifiedpath, or if the specifiedpathacts as the parent of a new child being added.value- The value to set at the specific path, in JSON formatted GlideString.- Returns:
- A simple
"OK"response if the value is successfully set. - Example:
String value = Json.set(client, gs("doc"), gs("."), gs("{\"a\": 1.0, \"b\": 2}")).get(); assert value.equals("OK");
-
set
public static java.util.concurrent.CompletableFuture<java.lang.String> set(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, @NonNull @NonNull java.lang.String value, @NonNull @NonNull ConditionalChange setCondition)Sets the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be set. The key will be modified only ifvalueis added as the last child in the specifiedpath, or if the specifiedpathacts as the parent of a new child being added.value- The value to set at the specific path, in JSON formatted string.setCondition- Set the value only if the given condition is met (within the key or path).- Returns:
- A simple
"OK"response if the value is successfully set. If value isn't set because ofsetCondition, returnsnull. - Example:
String value = Json.set(client, "doc", ".", "{\"a\": 1.0, \"b\": 2}", ConditionalChange.ONLY_IF_DOES_NOT_EXIST).get(); assert value.equals("OK");
-
set
public static java.util.concurrent.CompletableFuture<java.lang.String> set(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, @NonNull @NonNull GlideString value, @NonNull @NonNull ConditionalChange setCondition)Sets the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be set. The key will be modified only ifvalueis added as the last child in the specifiedpath, or if the specifiedpathacts as the parent of a new child being added.value- The value to set at the specific path, in JSON formatted GlideString.setCondition- Set the value only if the given condition is met (within the key or path).- Returns:
- A simple
"OK"response if the value is successfully set. If value isn't set because ofsetCondition, returnsnull. - Example:
String value = Json.set(client, gs("doc"), gs("."), gs("{\"a\": 1.0, \"b\": 2}"), ConditionalChange.ONLY_IF_DOES_NOT_EXIST).get(); assert value.equals("OK");
-
get
public static java.util.concurrent.CompletableFuture<java.lang.String> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Retrieves the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- Returns a string representation of the JSON document. If
keydoesn't exist, returnsnull. - Example:
String value = Json.get(client, "doc").get(); assert value.equals("{\"a\": 1.0, \"b\": 2}");
-
get
public static java.util.concurrent.CompletableFuture<GlideString> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)
Retrieves the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- Returns a string representation of the JSON document. If
keydoesn't exist, returnsnull. - Example:
GlideString value = Json.get(client, gs("doc")).get(); assert value.equals(gs("{\"a\": 1.0, \"b\": 2}"));
-
get
public static java.util.concurrent.CompletableFuture<java.lang.String> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String[] paths)Retrieves the JSON value at the specifiedpathsstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.paths- List of paths within the JSON document.- Returns:
- If one path is given:
- For JSONPath (path starts with
$): Returns a stringified JSON list replies for every possible path, or a string representation of an empty array, if path doesn't exist. Ifkeydoesn't exist, returnsnull. - For legacy path (path doesn't start with
$): Returns a string representation of the value inpaths. Ifpathsdoesn't exist, an error is raised. Ifkeydoesn't exist, returnsnull.
- For JSONPath (path starts with
- If multiple paths are given: Returns a stringified JSON, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
pathsare a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.- If one path is given:
- Example:
String value = Json.get(client, "doc", new String[] {"$"}).get(); assert value.equals("{\"a\": 1.0, \"b\": 2}"); String value = Json.get(client, "doc", new String[] {"$.a", "$.b"}).get(); assert value.equals("{\"$.a\": [1.0], \"$.b\": [2]}");
-
get
public static java.util.concurrent.CompletableFuture<GlideString> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString[] paths)
Retrieves the JSON value at the specifiedpathsstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.paths- List of paths within the JSON document.- Returns:
- If one path is given:
- For JSONPath (path starts with
$): Returns a stringified JSON list replies for every possible path, or a string representation of an empty array, if path doesn't exist. Ifkeydoesn't exist, returnsnull. - For legacy path (path doesn't start with
$): Returns a string representation of the value inpaths. Ifpathsdoesn't exist, an error is raised. Ifkeydoesn't exist, returnsnull.
- For JSONPath (path starts with
- If multiple paths are given: Returns a stringified JSON, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
pathsare a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.- If one path is given:
- Example:
GlideString value = Json.get(client, gs("doc"), new GlideString[] {gs("$")}).get(); assert value.equals(gs("{\"a\": 1.0, \"b\": 2}")); GlideString value = Json.get(client, gs("doc"), new GlideString[] {gs("$.a"), gs("$.b")}).get(); assert value.equals(gs("{\"$.a\": [1.0], \"$.b\": [2]}"));
-
get
public static java.util.concurrent.CompletableFuture<java.lang.String> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull JsonGetOptions options)Retrieves the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.options- Options for formatting the byte representation of the JSON data. SeeJsonGetOptions.- Returns:
- Returns a string representation of the JSON document. If
keydoesn't exist, returnsnull. - Example:
JsonGetOptions options = JsonGetOptions.builder() .indent(" ") .space(" ") .newline("\n") .build(); String value = Json.get(client, "doc", "$", options).get(); assert value.equals("{\n \"a\": \n 1.0\n ,\n \"b\": \n 2\n }");
-
get
public static java.util.concurrent.CompletableFuture<GlideString> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull JsonGetOptionsBinary options)
Retrieves the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.options- Options for formatting the byte representation of the JSON data. SeeJsonGetOptions.- Returns:
- Returns a string representation of the JSON document. If
keydoesn't exist, returnsnull. - Example:
JsonGetOptions options = JsonGetOptions.builder() .indent(" ") .space(" ") .newline("\n") .build(); GlideString value = Json.get(client, gs("doc"), gs("$"), options).get(); assert value.equals(gs("{\n \"a\": \n 1.0\n ,\n \"b\": \n 2\n }"));
-
get
public static java.util.concurrent.CompletableFuture<java.lang.String> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String[] paths, @NonNull @NonNull JsonGetOptions options)Retrieves the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.paths- List of paths within the JSON document.options- Options for formatting the byte representation of the JSON data. SeeJsonGetOptions.- Returns:
- If one path is given:
- For JSONPath (path starts with
$): Returns a stringified JSON list replies for every possible path, or a string representation of an empty array, if path doesn't exist. Ifkeydoesn't exist, returnsnull. - For legacy path (path doesn't start with
$): Returns a string representation of the value inpaths. Ifpathsdoesn't exist, an error is raised. Ifkeydoesn't exist, returnsnull.
- For JSONPath (path starts with
- If multiple paths are given: Returns a stringified JSON, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
pathsare a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.- If one path is given:
- Example:
JsonGetOptions options = JsonGetOptions.builder() .indent(" ") .space(" ") .newline("\n") .build(); String value = Json.get(client, "doc", new String[] {"$.a", "$.b"}, options).get(); assert value.equals("{\n \"$.a\": [\n 1.0\n ],\n \"$.b\": [\n 2\n ]\n}");
-
get
public static java.util.concurrent.CompletableFuture<GlideString> get(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString[] paths, @NonNull @NonNull JsonGetOptionsBinary options)
Retrieves the JSON value at the specifiedpathstored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.paths- List of paths within the JSON document.options- Options for formatting the byte representation of the JSON data. SeeJsonGetOptions.- Returns:
- If one path is given:
- For JSONPath (path starts with
$): Returns a stringified JSON list replies for every possible path, or a string representation of an empty array, if path doesn't exist. Ifkeydoesn't exist, returnsnull. - For legacy path (path doesn't start with
$): Returns a string representation of the value inpaths. Ifpathsdoesn't exist, an error is raised. Ifkeydoesn't exist, returnsnull.
- For JSONPath (path starts with
- If multiple paths are given: Returns a stringified JSON, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
pathsare a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.- If one path is given:
- Example:
JsonGetOptions options = JsonGetOptions.builder() .indent(" ") .space(" ") .newline("\n") .build(); GlideString value = Json.get(client, gs("doc"), new GlideString[] {gs("$.a"), gs("$.b")}, options).get(); assert value.equals(gs("{\n \"$.a\": [\n 1.0\n ],\n \"$.b\": [\n 2\n ]\n}"));
-
mget
public static java.util.concurrent.CompletableFuture<java.lang.String[]> mget(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String[] keys, @NonNull @NonNull java.lang.String path)Retrieves the JSON values at the specifiedpathstored at multiplekeys.- Parameters:
client- The client to execute the command.keys- The keys of the JSON documents.path- The path within the JSON documents.- Returns:
- An array with requested values for each key.
- For JSONPath (path starts with
$): Returns a stringified JSON list replies for every possible path, or a string representation of an empty array, if path doesn't exist. - For legacy path (path doesn't start with
$): Returns a string representation of the value inpath. Ifpathdoesn't exist, the corresponding array element will benull.
keydoesn't exist, the corresponding array element will benull. - For JSONPath (path starts with
- Example:
Json.set(client, "doc1", "$", "{\"a\": 1, \"b\": [\"one\", \"two\"]}").get(); Json.set(client, "doc2", "$", "{\"a\": 1, \"c\": false}").get(); var res = Json.mget(client, new String[] { "doc1", "doc2", "non_existing" }, "$.c").get(); assert Arrays.equals(res, new String[] { "[]", "[false]", null });
-
mget
public static java.util.concurrent.CompletableFuture<GlideString[]> mget(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString[] keys, @NonNull @NonNull GlideString path)
Retrieves the JSON values at the specifiedpathstored at multiplekeys.- Parameters:
client- The client to execute the command.keys- The keys of the JSON documents.path- The path within the JSON documents.- Returns:
- An array with requested values for each key.
- For JSONPath (path starts with
$): Returns a stringified JSON list replies for every possible path, or a string representation of an empty array, if path doesn't exist. - For legacy path (path doesn't start with
$): Returns a string representation of the value inpath. Ifpathdoesn't exist, the corresponding array element will benull.
keydoesn't exist, the corresponding array element will benull. - For JSONPath (path starts with
- Example:
Json.set(client, "doc1", "$", "{\"a\": 1, \"b\": [\"one\", \"two\"]}").get(); Json.set(client, "doc2", "$", "{\"a\": 1, \"c\": false}").get(); var res = Json.mget(client, new GlideString[] { gs("doc1"), gs("doc2"), gs("doc3") }, gs("$.c")).get(); assert Arrays.equals(res, new GlideString[] { gs("[]"), gs("[false]"), null });
-
arrappend
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrappend(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, @NonNull @NonNull java.lang.String[] values)Appends one or morevaluesto the JSON array at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- Thekeyof the JSON document.path- Represents thepathwithin the JSON document where thevalueswill be appended.values- The JSON values to be appended to the array.
JSON string values must be wrapped with quotes. For example, to append"foo", pass"\"foo\"".- Returns:
- For JSONPath (
pathstarts with$):
Returns a list of integers for every possible path, indicating the new length of the array after appendingvalues, ornullfor JSON values matching the path that are not an array. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns the new length of the array after appendingvaluesto the array atpath. If multiple paths are matched, returns the last updated array. If the JSON value atpathis not a array or ifpathdoesn't exist, an error is raised. Ifkeydoesn't exist, an error is raised.
- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1, \"b\": [\"one\", \"two\"]}").get(); var res = Json.arrappend(client, "doc", "$.b", new String[] {"\"three\""}).get(); assert Arrays.equals((Object[]) res, new int[] {3}); // New length of the array after appending res = Json.arrappend(client, "doc", ".b", new String[] {"\"four\""}).get(); assert res.equals(4); // New length of the array after appending
-
arrappend
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrappend(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, @NonNull @NonNull GlideString[] values)Appends one or morevaluesto the JSON array at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- Thekeyof the JSON document.path- Represents thepathwithin the JSON document where thevalueswill be appended.values- The JSON values to be appended to the array.
JSON string values must be wrapped with quotes. For example, to append"foo", pass"\"foo\"".- Returns:
- For JSONPath (
pathstarts with$):
Returns a list of integers for every possible path, indicating the new length of the new array after appendingvalues, ornullfor JSON values matching the path that are not an array. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns the length of the new array after appendingvaluesto the array atpath. If multiple paths are matched, returns the last updated array. If the JSON value atpathis not a array or ifpathdoesn't exist, an error is raised. Ifkeydoesn't exist, an error is raised.
- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1, \"b\": [\"one\", \"two\"]}").get(); var res = Json.arrappend(client, gs("doc"), gs("$.b"), new GlideString[] {gs("\"three\"")}).get(); assert Arrays.equals((Object[]) res, new int[] {3}); // New length of the array after appending res = Json.arrappend(client, gs("doc"), gs(".b"), new GlideString[] {gs("\"four\"")}).get(); assert res.equals(4); // New length of the array after appending
-
arrinsert
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrinsert(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, int index, @NonNull @NonNull java.lang.String[] values)Inserts one or more values into the array at the specifiedpathwithin the JSON document stored atkey, before the givenindex.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.index- The array index before which values are inserted.values- The JSON values to be inserted into the array.
JSON string values must be wrapped with quotes. For example, to insert"foo", pass"\"foo\"".- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of integers for every possible path, indicating the new length of the array, ornullfor JSON values matching the path that are not an array. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the new length of the array. If multiple paths are matched, returns the length of the first modified array. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "[[], [\"a\"], [\"a\", \"b\"]]").get(); var newValues = new String[] { "\"c\"", "{\"key\": \"value\"}", "true", "null", "[\"bar\"]" }; var res = Json.arrinsert(client, "doc", "$[*]", 0, newValues).get(); assert Arrays.equals((Object[]) res, new int[] { 5, 6, 7 }); // New lengths of arrays after insertion var doc = Json.get(client, "doc").get(); assert doc.equals("[[\"c\", {\"key\": \"value\"}, true, null, [\"bar\"]], [\"c\", {\"key\": \"value\"}, " + "true, null, [\"bar\"], \"a\"], [\"c\", {\"key\": \"value\"}, true, null, [\"bar\"], \"a\", \"b\"]]"); Json.set(client, "doc", "$", "[[], [\"a\"], [\"a\", \"b\"]]").get(); res = Json.arrinsert(client, "doc", ".", 0, new String[] { "\"c\"" }).get(); assert res == 4 // New length of the root array after insertion doc = Json.get(client, "doc").get(); assert doc.equals("[\"c\", [], [\"a\"], [\"a\", \"b\"]]");
-
arrinsert
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrinsert(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, int index, @NonNull @NonNull GlideString[] values)Inserts one or more values into the array at the specifiedpathwithin the JSON document stored atkey, before the givenindex.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.index- The array index before which values are inserted.values- The JSON values to be inserted into the array.
JSON string values must be wrapped with quotes. For example, to insert"foo", pass"\"foo\"".- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of integers for every possible path, indicating the new length of the array, ornullfor JSON values matching the path that are not an array. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the new length of the array. If multiple paths are matched, returns the length of the first modified array. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "[[], [\"a\"], [\"a\", \"b\"]]").get(); var newValues = new GlideString[] { gs("\"c\""), gs("{\"key\": \"value\"}"), gs("true"), gs("null"), gs("[\"bar\"]") }; var res = Json.arrinsert(client, gs("doc"), gs("$[*]"), 0, newValues).get(); assert Arrays.equals((Object[]) res, new int[] { 5, 6, 7 }); // New lengths of arrays after insertion var doc = Json.get(client, "doc").get(); assert doc.equals("[[\"c\", {\"key\": \"value\"}, true, null, [\"bar\"]], [\"c\", {\"key\": \"value\"}, " + "true, null, [\"bar\"], \"a\"], [\"c\", {\"key\": \"value\"}, true, null, [\"bar\"], \"a\", \"b\"]]"); Json.set(client, "doc", "$", "[[], [\"a\"], [\"a\", \"b\"]]").get(); res = Json.arrinsert(client, gs("doc"), gs("."), 0, new GlideString[] { gs("\"c\"") }).get(); assert res == 4 // New length of the root array after insertion doc = Json.get(client, "doc").get(); assert doc.equals("[\"c\", [], [\"a\"], [\"a\", \"b\"]]");
-
arrindex
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrindex(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, @NonNull @NonNull java.lang.String scalar)Searches for the first occurrence of ascalarJSON value in the arrays at the path.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.scalar- The scalar value to search for.- Returns:
- For JSONPath (
pathstarts with$): Returns an array with a list of integers for every possible path, indicating the index of the matching element. The value is-1if not found. If a value is not an array, its corresponding return value isnull. - For legacy path (path doesn't start with
$): Returns an integer representing the index of matching element, or-1if not found. If the value at thepathis not an array, an error is raised.
- For JSONPath (
- Example:
Json.set(client, key, "$", "{\"a\": [\"value\", 3], \"b\": {\"a\": [3, [\"value\", false], 5]}}").get(); var result = Json.arrindex(client, key, "$..a", "3").get(); assert Arrays.equals((Object[]) result, new Object[] {1L, 0L}); result = Json.arrindex(client, key, "$..a", "\"value\"").get(); assert Arrays.equals((Object[]) result, new Object[] {0L, -1L});
-
arrindex
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrindex(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, @NonNull @NonNull GlideString scalar)Searches for the first occurrence of ascalarJSON value in the arrays at the path.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.scalar- The scalar value to search for.- Returns:
- For JSONPath (
pathstarts with$): Returns an array with a list of integers for every possible path, indicating the index of the matching element. The value is-1if not found. If a value is not an array, its corresponding return value isnull. - For legacy path (path doesn't start with
$): Returns an integer representing the index of matching element, or-1if not found. If the value at thepathis not an array, an error is raised.
- For JSONPath (
- Example:
Json.set(client, key, "$", "{\"a\": [\"value\", 3], \"b\": {\"a\": [3, [\"value\", false], 5]}}").get(); var result = Json.arrindex(client, gs(key), gs("$..a"), gs("3")).get(); assert Arrays.equals((Object[]) result, new Object[] {1L, 0L}); // Searches for the first occurrence of null in the arrays result = Json.arrindex(client, gs(key), gs("$..a"), gs("null")).get(); assert Arrays.equals((Object[]) result, new Object[] {-1L, -1L});
-
arrindex
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrindex(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, @NonNull @NonNull java.lang.String scalar, @NonNull @NonNull JsonArrindexOptions options)Searches for the first occurrence of ascalarJSON value in the arrays at the path.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.scalar- The scalar value to search for.options- The additional options for the command. SeeJsonArrindexOptions.- Returns:
- For JSONPath (
pathstarts with$): Returns an array with a list of integers for every possible path, indicating the index of the matching element. The value is-1if not found. If a value is not an array, its corresponding return value isnull. - For legacy path (path doesn't start with
$): Returns an integer representing the index of matching element, or-1if not found. If the value at thepathis not an array, an error is raised.
- For JSONPath (
- Example:
Json.set(client, key, "$", "{\"a\": [\"value\", 3], \"b\": {\"a\": [3, [\"value\", false], 5]}}").get(); var result = Json.arrindex(client, key, ".a", "3", new JsonArrindexOptions(0L)).get(); assert Arrays.equals(1L, result);
-
arrindex
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrindex(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, @NonNull @NonNull GlideString scalar, @NonNull @NonNull JsonArrindexOptions options)Searches for the first occurrence of ascalarJSON value in the arrays at the path.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.scalar- The scalar value to search for.options- The additional options for the command. SeeJsonArrindexOptions.- Returns:
- For JSONPath (
pathstarts with$): Returns an array with a list of integers for every possible path, indicating the index of the matching element. The value is-1if not found. If a value is not an array, its corresponding return value isnull.. - For legacy path (path doesn't start with
$): Returns an integer representing the index of matching element, or-1if not found. If the value at thepathis not an array, an error is raised.
- For JSONPath (
- Example:
Json.set(client, key, "$", "{\"a\": [\"value\", 3], \"b\": {\"a\": [3, [\"value\", false], 5]}}").get(); var result = Json.arrindex(client, gs(key), gs(".a"), gs("3"), new JsonArrindexOptions(0L)).get(); assert Arrays.equals(1L, result);
-
arrlen
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Retrieves the length of the array at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of integers for every possible path, indicating the length of the array, ornullfor JSON values matching the path that are not an array. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the length of the array. If multiple paths are matched, returns the length of the first matching array. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": [1, 2, 3], \"b\": {\"a\": [1, 2], \"c\": {\"a\": 42}}}").get(); var res = Json.arrlen(client, "doc", "$").get(); assert Arrays.equals((Object[]) res, new Object[] { null }); // No array at the root path. res = Json.arrlen(client, "doc", "$.a").get(); assert Arrays.equals((Object[]) res, new Object[] { 3 }); // Retrieves the length of the array at path $.a. res = Json.arrlen(client, "doc", "$..a").get(); assert Arrays.equals((Object[]) res, new Object[] { 3, 2, null }); // Retrieves lengths of arrays found at all levels of the path `..a`. res = Json.arrlen(client, "doc", "..a").get(); assert res == 3; // Legacy path retrieves the first array match at path `..a`.
-
arrlen
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Retrieves the length of the array at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of integers for every possible path, indicating the length of the array, ornullfor JSON values matching the path that are not an array. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the length of the array. If multiple paths are matched, returns the length of the first matching array. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": [1, 2, 3], \"b\": {\"a\": [1, 2], \"c\": {\"a\": 42}}}").get(); var res = Json.arrlen(client, gs("doc"), gs("$")).get(); assert Arrays.equals((Object[]) res, new Object[] { null }); // No array at the root path. res = Json.arrlen(client, gs("doc"), gs("$.a")).get(); assert Arrays.equals((Object[]) res, new Object[] { 3 }); // Retrieves the length of the array at path $.a. res = Json.arrlen(client, gs("doc"), gs("$..a")).get(); assert Arrays.equals((Object[]) res, new Object[] { 3, 2, null }); // Retrieves lengths of arrays found at all levels of the path `..a`. res = Json.arrlen(client, gs("doc"), gs("..a")).get(); assert res == 3; // Legacy path retrieves the first array match at path `..a`.
-
arrlen
public static java.util.concurrent.CompletableFuture<java.lang.Long> arrlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Retrieves the length of the array at the root of the JSON document stored atkey.
Equivalent toarrlen(BaseClient, String, String)withpathset to".".- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The array length stored at the root of the document. If document root is not an array,
an error is raised.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "[1, 2, true, null, \"tree\"]").get(); var res = Json.arrlen(client, "doc").get(); assert res == 5;
-
arrlen
public static java.util.concurrent.CompletableFuture<java.lang.Long> arrlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Retrieves the length of the array at the root of the JSON document stored atkey. Equivalent toarrlen(BaseClient, GlideString, GlideString)withpathset togs(".").- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The array length stored at the root of the document. If document root is not an array,
an error is raised.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "[1, 2, true, null, \"tree\"]").get(); var res = Json.arrlen(client, gs("doc")).get(); assert res == 5;
-
debugMemory
public static java.util.concurrent.CompletableFuture<java.lang.Object> debugMemory(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of numbers for every possible path, indicating the memory usage. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the memory usage. If multiple paths are matched, returns the data of the first matching object. Ifpathdoesn't exist, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
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;
-
debugFields
public static java.util.concurrent.CompletableFuture<java.lang.Object> debugFields(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field. Objects and arrays recursively count one field for each of their containing JSON values. Each container value, except the root container, counts as one additional field.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of numbers for every possible path, indicating the number of fields. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the number of fields. If multiple paths are matched, returns the data of the first matching object. Ifpathdoesn't exist, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "[1, 2.3, \"foo\", true, null, {}, [], {\"a\":1, \"b\":2}, [1, 2, 3]]").get(); var res = Json.debugFields(client, "doc", "$[*]").get(); assert Arrays.equals((Object[]) res, new Object[] {1, 1, 1, 1, 1, 0, 0, 2, 3});
-
debugMemory
public static java.util.concurrent.CompletableFuture<java.lang.Object> debugMemory(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of numbers for every possible path, indicating the memory usage. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the memory usage. If multiple paths are matched, returns the data of the first matching object. Ifpathdoesn't exist, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "[1, 2.3, \"foo\", true, null, {}, [], {\"a\":1, \"b\":2}, [1, 2, 3]]").get(); var res = Json.debugMemory(client, gs("doc"), gs("..")).get(); assert res == 258L;
-
debugFields
public static java.util.concurrent.CompletableFuture<java.lang.Object> debugFields(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field. Objects and arrays recursively count one field for each of their containing JSON values. Each container value, except the root container, counts as one additional field.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of numbers for every possible path, indicating the number of fields. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the number of fields. If multiple paths are matched, returns the data of the first matching object. Ifpathdoesn't exist, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "[1, 2.3, \"foo\", true, null, {}, [], {\"a\":1, \"b\":2}, [1, 2, 3]]").get(); var res = Json.debugFields(client, gs("doc"), gs("$[*]")).get(); assert Arrays.equals((Object[]) res, new Object[] {1, 1, 1, 1, 1, 0, 0, 2, 3});
-
debugMemory
public static java.util.concurrent.CompletableFuture<java.lang.Long> debugMemory(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.
Equivalent todebugMemory(BaseClient, String, String)withpathset to"..".- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The total memory usage in bytes of the entire JSON document.
Ifkeydoesn't exist, returnsnull. - Example:
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;
-
debugFields
public static java.util.concurrent.CompletableFuture<java.lang.Long> debugFields(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field. Objects and arrays recursively count one field for each of their containing JSON values. Each container value, except the root container, counts as one additional field.
Equivalent todebugFields(BaseClient, String, String)withpathset to"..".- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The total number of fields in the entire JSON document.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "[1, 2.3, \"foo\", true, null, {}, [], {\"a\":1, \"b\":2}, [1, 2, 3]]").get(); var res = Json.debugFields(client, "doc").get(); assert res == 14L;
-
debugMemory
public static java.util.concurrent.CompletableFuture<java.lang.Long> debugMemory(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Reports memory usage in bytes of a JSON object at the specifiedpathwithin the JSON document stored atkey.
Equivalent todebugMemory(BaseClient, GlideString, GlideString)withpathset togs("..").- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The total memory usage in bytes of the entire JSON document.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "[1, 2.3, \"foo\", true, null, {}, [], {\"a\":1, \"b\":2}, [1, 2, 3]]").get(); var res = Json.debugMemory(client, gs("doc")).get(); assert res == 258L;
-
debugFields
public static java.util.concurrent.CompletableFuture<java.lang.Long> debugFields(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Reports the number of fields at the specifiedpathwithin the JSON document stored atkey.
Each non-container JSON value counts as one field. Objects and arrays recursively count one field for each of their containing JSON values. Each container value, except the root container, counts as one additional field.
Equivalent todebugFields(BaseClient, GlideString, GlideString)withpathset togs("..").- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The total number of fields in the entire JSON document.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "[1, 2.3, \"foo\", true, null, {}, [], {\"a\":1, \"b\":2}, [1, 2, 3]]").get(); var res = Json.debugFields(client, gs("doc")).get(); assert res == 14L;
-
arrpop
public static java.util.concurrent.CompletableFuture<java.lang.String> arrpop(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Pops the last element from the array stored in the root of the JSON document stored atkey. Equivalent toarrpop(BaseClient, String, String)withpathset to".".- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- Returns a string representing the popped JSON value, or
nullif the array at document root is empty.
If the JSON value at document root is not an array or ifkeydoesn't exist, an error is raised. - Example:
Json.set(client, "doc", "$", "[1, 2, true, {\"a\": 42, \"b\": 33}, \"tree\"]").get(); var res = Json.arrpop(client, "doc").get(); assert res.equals("\"tree\""); res = Json.arrpop(client, "doc").get(); assert res.equals("{\"a\": 42, \"b\": 33}");
-
arrpop
public static java.util.concurrent.CompletableFuture<GlideString> arrpop(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)
Pops the last element from the array located in the root of the JSON document stored atkey. Equivalent toarrpop(BaseClient, GlideString, GlideString)withpathset togs(".").- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- Returns a string representing the popped JSON value, or
nullif the array at document root is empty.
If the JSON value at document root is not an array or ifkeydoesn't exist, an error is raised. - Example:
Json.set(client, "doc", "$", "[1, 2, true, {\"a\": 42, \"b\": 33}, \"tree\"]").get(); var res = Json.arrpop(client, gs("doc")).get(); assert res.equals(gs("\"tree\"")); res = Json.arrpop(client, gs("doc")).get(); assert res.equals(gs("{\"a\": 42, \"b\": 33}"));
-
arrpop
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrpop(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Pops the last element from the array located atpathin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns an array with a strings for every possible path, representing the popped JSON values, ornullfor JSON values matching the path that are not an array or an empty array. - For legacy path (
pathdoesn't start with$):
Returns a string representing the popped JSON value, ornullif the array atpathis empty. If multiple paths are matched, the value from the first matching array that is not empty is returned. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "[1, 2, true, {\"a\": 42, \"b\": 33}, \"tree\"]").get(); var res = Json.arrpop(client, "doc", "$").get(); assert Arrays.equals((Object[]) res, new Object[] { "\"tree\"" }); res = Json.arrpop(client, "doc", ".").get(); assert res.equals("{\"a\": 42, \"b\": 33}");
-
arrpop
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrpop(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Pops the last element from the array located atpathin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns an array with a strings for every possible path, representing the popped JSON values, ornullfor JSON values matching the path that are not an array or an empty array. - For legacy path (
pathdoesn't start with$):
Returns a string representing the popped JSON value, ornullif the array atpathis empty. If multiple paths are matched, the value from the first matching array that is not empty is returned. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "[1, 2, true, {\"a\": 42, \"b\": 33}, \"tree\"]").get(); var res = Json.arrpop(client, gs("doc"), gs("$")).get(); assert Arrays.equals((Object[]) res, new Object[] { gs("\"tree\"") }); res = Json.arrpop(client, gs("doc"), gs(".")).get(); assert res.equals(gs("{\"a\": 42, \"b\": 33}"));
-
arrpop
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrpop(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, long index)Pops an element from the array located atpathin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- The path within the JSON document.index- The index of the element to pop. Out of boundary indexes are rounded to their respective array boundaries.- Returns:
- For JSONPath (
pathstarts with$):
Returns an array with a strings for every possible path, representing the popped JSON values, ornullfor JSON values matching the path that are not an array or an empty array. - For legacy path (
pathdoesn't start with$):
Returns a string representing the popped JSON value, ornullif the array atpathis empty. If multiple paths are matched, the value from the first matching array that is not empty is returned. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, an error is raised.- For JSONPath (
- Example:
String doc = "{\"a\": [1, 2, true], \"b\": {\"a\": [3, 4, [\"value\", 3, false], 5], \"c\": {\"a\": 42}}}"; Json.set(client, "doc", "$", doc).get(); var res = Json.arrpop(client, "doc", "$.a", 1).get(); assert res.equals("2"); // Pop second element from array at path `$.a` Json.set(client, "doc", "$", "[[], [\"a\"], [\"a\", \"b\", \"c\"]]").get(); res = Json.arrpop(client, "doc", ".", -1).get()); assert res.equals("[\"a\", \"b\", \"c\"]"); // Pop last elements at path `.`
-
arrpop
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrpop(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, long index)Pops an element from the array located atpathin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- The path within the JSON document.index- The index of the element to pop. Out of boundary indexes are rounded to their respective array boundaries.- Returns:
- For JSONPath (
pathstarts with$):
Returns an array with a strings for every possible path, representing the popped JSON values, ornullfor JSON values matching the path that are not an array or an empty array. - For legacy path (
pathdoesn't start with$):
Returns a string representing the popped JSON value, ornullif the array atpathis empty. If multiple paths are matched, the value from the first matching array that is not empty is returned. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, an error is raised.- For JSONPath (
- Example:
String doc = "{\"a\": [1, 2, true], \"b\": {\"a\": [3, 4, [\"value\", 3, false], 5], \"c\": {\"a\": 42}}}"; Json.set(client, "doc", "$", doc).get(); var res = Json.arrpop(client, gs("doc"), gs("$.a"), 1).get(); assert res.equals("2"); // Pop second element from array at path `$.a` Json.set(client, "doc", "$", "[[], [\"a\"], [\"a\", \"b\", \"c\"]]").get(); res = Json.arrpop(client, gs("doc"), gs("."), -1).get()); assert res.equals(gs("[\"a\", \"b\", \"c\"]")); // Pop last elements at path `.`
-
arrtrim
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrtrim(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, int start, int end)Trims an array at the specifiedpathwithin the JSON document stored atkeyso that it becomes a subarray [start,end], both inclusive.
Ifstart< 0, it is treated as 0.
Ifend>= size (size of the array), it is treated as size -1.
Ifstart>= size orstart>end, the array is emptied and 0 is return.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.start- The index of the first element to keep, inclusive.end- The index of the last element to keep, inclusive.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of integers for every possible path, indicating the new length of the array, ornullfor JSON values matching the path that are not an array. If the array is empty, its corresponding return value is 0. Ifpathdoesn't exist, an empty array will be return. If an index argument is out of bounds, an error is raised. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the new length of the array. If the array is empty, its corresponding return value is 0. If multiple paths match, the length of the first trimmed array match is returned. Ifpathdoesn't exist, or the value atpathis not an array, an error is raised. If an index argument is out of bounds, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{[], [\"a\"], [\"a\", \"b\"], [\"a\", \"b\", \"c\"]}").get(); var res = Json.arrtrim(client, "doc", "$[*]", 0, 1).get(); assert Arrays.equals((Object[]) res, new Object[] { 0, 1, 2, 2 }); // New lengths of arrays after trimming Json.set(client, "doc", "$", "{\"children\": [\"John\", \"Jack\", \"Tom\", \"Bob\", \"Mike\"]}").get(); res = Json.arrtrim(client, "doc", ".children", 0, 1).get(); assert res == 2; // new length after trimming
-
arrtrim
public static java.util.concurrent.CompletableFuture<java.lang.Object> arrtrim(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, int start, int end)Trims an array at the specifiedpathwithin the JSON document stored atkeyso that it becomes a subarray [start,end], both inclusive.
Ifstart< 0, it is treated as 0.
Ifend>= size (size of the array), it is treated as size -1.
Ifstart>= size orstart>end, the array is emptied and 0 is return.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.start- The index of the first element to keep, inclusive.end- The index of the last element to keep, inclusive.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of integers for every possible path, indicating the new length of the array, ornullfor JSON values matching the path that are not an array. If the array is empty, its corresponding return value is 0. Ifpathdoesn't exist, an empty array will be return. If an index argument is out of bounds, an error is raised. - For legacy path (
pathdoesn't start with$):
Returns an integer representing the new length of the array. If the array is empty, its corresponding return value is 0. If multiple paths match, the length of the first trimmed array match is returned. Ifpathdoesn't exist, or the value atpathis not an array, an error is raised. If an index argument is out of bounds, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{[], [\"a\"], [\"a\", \"b\"], [\"a\", \"b\", \"c\"]}").get(); var res = Json.arrtrim(client, gs("doc"), gs("$[*]"), 0, 1).get(); assert Arrays.equals((Object[]) res, new Object[] { 0, 1, 2, 2 }); // New lengths of arrays after trimming Json.set(client, "doc", "$", "{\"children\": [\"John\", \"Jack\", \"Tom\", \"Bob\", \"Mike\"]}").get(); res = Json.arrtrim(client, gs("doc"), gs(".children"), 0, 1).get(); assert res == 2; // new length after trimming
-
numincrby
public static java.util.concurrent.CompletableFuture<java.lang.String> numincrby(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, java.lang.Number number)Increments or decrements the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.number- The number to increment or decrement by.- Returns:
- For JSONPath (
pathstarts with$):
Returns a string representation of an array of strings, indicating the new values after incrementing for each matchedpath.
If a value is not a number, its corresponding return value will benull.
Ifpathdoesn't exist, a byte string representation of an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns a string representation of the resulting value after the increment or decrement.
If multiple paths match, the result of the last updated value is returned.
If the value at thepathis not a number orpathdoesn't exist, an error is raised.
keydoes not exist, an error is raised.
If the result is out of the range of 64-bit IEEE double, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"c\": [1, 2], \"d\": [1, 2, 3]}").get(); var res = Json.numincrby(client, "doc", "$.d[*]", 10.0).get(); assert res.equals("[11,12,13]"); // Increment each element in `d` array by 10. res = Json.numincrby(client, "doc", ".c[1]", 10.0).get(); assert res.equals("12"); // Increment the second element in the `c` array by 10.
-
numincrby
public static java.util.concurrent.CompletableFuture<GlideString> numincrby(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, java.lang.Number number)
Increments or decrements the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.number- The number to increment or decrement by.- Returns:
- For JSONPath (
pathstarts with$):
Returns aGlideStringrepresentation of an array of strings, indicating the new values after incrementing for each matchedpath.
If a value is not a number, its corresponding return value will benull.
Ifpathdoesn't exist, a byte string representation of an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns aGlideStringrepresentation of the resulting value after the increment or decrement.
If multiple paths match, the result of the last updated value is returned.
If the value at thepathis not a number orpathdoesn't exist, an error is raised.
keydoes not exist, an error is raised.
If the result is out of the range of 64-bit IEEE double, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"c\": [1, 2], \"d\": [1, 2, 3]}").get(); var res = Json.numincrby(client, gs("doc"), gs("$.d[*]"), 10.0).get(); assert res.equals(gs("[11,12,13]")); // Increment each element in `d` array by 10. res = Json.numincrby(client, gs("doc"), gs(".c[1]"), 10.0).get(); assert res.equals(gs("12")); // Increment the second element in the `c` array by 10.
-
nummultby
public static java.util.concurrent.CompletableFuture<java.lang.String> nummultby(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path, java.lang.Number number)Multiplies the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.number- The number to multiply by.- Returns:
- For JSONPath (
pathstarts with$):
Returns a string representation of an array of strings, indicating the new values after multiplication for each matchedpath.
If a value is not a number, its corresponding return value will benull.
Ifpathdoesn't exist, a byte string representation of an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns a string representation of the resulting value after multiplication.
If multiple paths match, the result of the last updated value is returned.
If the value at thepathis not a number orpathdoesn't exist, an error is raised.
keydoes not exist, an error is raised.
If the result is out of the range of 64-bit IEEE double, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"c\": [1, 2], \"d\": [1, 2, 3]}").get(); var res = Json.nummultby(client, "doc", "$.d[*]", 2.0).get(); assert res.equals("[2,4,6]"); // Multiplies each element in the `d` array by 2. res = Json.nummultby(client, "doc", ".c[1]", 2.0).get(); assert res.equals("12"); // Multiplies the second element in the `c` array by 2.
-
nummultby
public static java.util.concurrent.CompletableFuture<GlideString> nummultby(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path, java.lang.Number number)
Multiplies the JSON value(s) at the specifiedpathbynumberwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.number- The number to multiply by.- Returns:
- For JSONPath (
pathstarts with$):
Returns aGlideStringrepresentation of an array of strings, indicating the new values after multiplication for each matchedpath.
If a value is not a number, its corresponding return value will benull.
Ifpathdoesn't exist, a byte string representation of an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns aGlideStringrepresentation of the resulting value after multiplication.
If multiple paths match, the result of the last updated value is returned.
If the value at thepathis not a number orpathdoesn't exist, an error is raised.
keydoes not exist, an error is raised.
If the result is out of the range of 64-bit IEEE double, an error is raised.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"c\": [1, 2], \"d\": [1, 2, 3]}").get(); var res = Json.nummultby(client, gs("doc"), gs("$.d[*]"), 2.0).get(); assert res.equals(gs("[2,4,6]")); // Multiplies each element in the `d` array by 2. res = Json.nummultby(client, gs("doc"), gs(".c[1]"), 2.0).get(); assert res.equals(gs("12")); // Multiplies the second element in the `c` array by 2.
-
objlen
public static java.util.concurrent.CompletableFuture<java.lang.Long> objlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjlen(BaseClient, String, String)withpathset to".".- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The object length stored at the root of the document. If document root is not an
object, an error is raised.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objlen(client, "doc").get(); assert res == 2; // the size of object matching the path `.`, which has 2 keys: 'a' and 'b'.
-
objlen
public static java.util.concurrent.CompletableFuture<java.lang.Long> objlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjlen(BaseClient, GlideString, GlideString)withpathset togs(".").- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The object length stored at the root of the document. If document root is not an
object, an error is raised.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objlen(client, gs("doc"), gs(".")).get(); assert res == 2; // the size of object matching the path `.`, which has 2 keys: 'a' and 'b'.
-
objlen
public static java.util.concurrent.CompletableFuture<java.lang.Object> objlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of long integers for every possible path, indicating the number of key-value pairs for each matching object, ornullfor JSON values matching the path that are not an object. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns the number of key-value pairs for the object value matching the path. If multiple paths are matched, returns the length of the first matching object. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objlen(client, "doc", ".").get(); // legacy path - command returns first value as `Long` assert res == 2L; // the size of object matching the path `.`, which has 2 keys: 'a' and 'b'. res = Json.objlen(client, "doc", "$.b").get(); // JSONPath - command returns an array assert Arrays.equals((Object[]) res, new Object[] { 3L }); // the length of the objects at path `$.b`
-
objlen
public static java.util.concurrent.CompletableFuture<java.lang.Object> objlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Retrieves the number of key-value pairs in the object values at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[]with a list of long integers for every possible path, indicating the number of key-value pairs for each matching object, ornullfor JSON values matching the path that are not an object. Ifpathdoes not exist, an empty array will be returned. - For legacy path (
pathdoesn't start with$):
Returns the number of key-value pairs for the object value matching the path. If multiple paths are matched, returns the length of the first matching object. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objlen(client, gs("doc"), gs(".")).get(); // legacy path - command returns first value as `Long` assert res == 2L; // the size of object matching the path `.`, which has 2 keys: 'a' and 'b'. res = Json.objlen(client, gs("doc"), gs("$.b")).get(); // JSONPath - command returns an array assert Arrays.equals((Object[]) res, new Object[] { 3L }); // the length of the objects at path `$.b`
-
objkeys
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> objkeys(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjkeys(BaseClient, String, String)withpathset to".".- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The object length stored at the root of the document. If document root is not an
object, an error is raised.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objkeys(client, "doc").get(); assert Arrays.equals((Object[]) res, new Object[] { "a", "b" }); // the keys of the object matching the path `.`, which has 2 keys: 'a' and 'b'.
-
objkeys
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> objkeys(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.
Equivalent toobjkeys(BaseClient, GlideString, GlideString)withpathset togs(".").- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- The object length stored at the root of the document. If document root is not an
object, an error is raised.
Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objkeys(client, gs("doc"), gs(".")).get(); assert Arrays.equals((Object[]) res, new Object[] { gs("a"), gs("b") }); // the keys of the object matching the path `.`, which has 2 keys: 'a' and 'b'.
-
objkeys
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> objkeys(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[][]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, ornullfor JSON values matching the path that are not an object. Ifpathdoes not exist, an empty sub-array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an array of object keys for the object value matching the path. If multiple paths are matched, returns the length of the first matching object. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objkeys(client, "doc", ".").get(); // legacy path - command returns array for first matched object assert Arrays.equals((Object[]) res, new Object[] { "a", "b" }); // key names for the object matching the path `.` as it is the only match. res = Json.objkeys(client, "doc", "$.b").get(); // JSONPath - command returns an array for each matched object assert Arrays.equals((Object[]) res, new Object[][] { { "a", "b", "c" } }); // key names as a nested list for objects matching the JSONPath `$.b`.
-
objkeys
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> objkeys(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Retrieves the key names in the object values at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns anObject[][]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, ornullfor JSON values matching the path that are not an object. Ifpathdoes not exist, an empty sub-array will be returned. - For legacy path (
pathdoesn't start with$):
Returns an array of object keys for the object value matching the path. If multiple paths are matched, returns the length of the first matching object. Ifpathdoesn't exist or the value atpathis not an array, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1.0, \"b\": {\"a\": {\"x\": 1, \"y\": 2}, \"b\": 2.5, \"c\": true}}").get(); var res = Json.objkeys(client, gs("doc"), gs(".")).get(); // legacy path - command returns array for first matched object assert Arrays.equals((Object[]) res, new Object[] { "a", "b" }); // key names for the object matching the path `.` as it is the only match. res = Json.objkeys(client, gs("doc"), gs("$.b")).get(); // JSONPath - command returns an array for each matched object assert Arrays.equals((Object[]) res, new Object[][] { { "a", "b", "c" } }); // key names as a nested list for objects matching the JSONPath `$.b`.
-
del
public static java.util.concurrent.CompletableFuture<java.lang.Long> del(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Deletes the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- The number of elements deleted. 0 if the key does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.del(client, "doc").get(); assert result == 1L;
-
del
public static java.util.concurrent.CompletableFuture<java.lang.Long> del(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Deletes the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- The number of elements deleted. 0 if the key does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.del(client, gs("doc")).get(); assert result == 1L;
-
del
public static java.util.concurrent.CompletableFuture<java.lang.Long> del(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be deleted.- Returns:
- The number of elements deleted. 0 if the key does not exist, or if the JSON path is invalid or does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.del(client, "doc", "$..a").get(); assert result == 2L;
-
del
public static java.util.concurrent.CompletableFuture<java.lang.Long> del(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be deleted.- Returns:
- The number of elements deleted. 0 if the key does not exist, or if the JSON path is invalid or does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.del(client, gs("doc"), gs("$..a")).get(); assert result == 2L;
-
forget
public static java.util.concurrent.CompletableFuture<java.lang.Long> forget(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Deletes the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- The number of elements deleted. 0 if the key does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.forget(client, "doc").get(); assert result == 1L;
-
forget
public static java.util.concurrent.CompletableFuture<java.lang.Long> forget(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Deletes the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.- Returns:
- The number of elements deleted. 0 if the key does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.forget(client, gs("doc")).get(); assert result == 1L;
-
forget
public static java.util.concurrent.CompletableFuture<java.lang.Long> forget(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be deleted.- Returns:
- The number of elements deleted. 0 if the key does not exist, or if the JSON path is invalid or does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.forget(client, "doc", "$..a").get(); assert result == 2L;
-
forget
public static java.util.concurrent.CompletableFuture<java.lang.Long> forget(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Deletes the JSON value at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- Thekeyof the JSON document.path- Represents the path within the JSON document where the value will be deleted.- Returns:
- The number of elements deleted. 0 if the key does not exist, or if the JSON path is invalid or does not exist.
- Example:
Json.set(client, "doc", ".", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); Long result = Json.forget(client, gs("doc"), gs("$..a")).get(); assert result == 2L;
-
toggle
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> toggle(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Toggles a Boolean value stored at the root within the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- Returns the toggled boolean value at the root of the document, or
nullfor JSON values matching the root that are not boolean. Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", ".", true).get(); var res = Json.toggle(client, "doc").get(); assert res.equals(false); res = Json.toggle(client, "doc").get(); assert res.equals(true);
-
toggle
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> toggle(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Toggles a Boolean value stored at the root within the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- Returns the toggled boolean value at the root of the document, or
nullfor JSON values matching the root that are not boolean. Ifkeydoesn't exist, returnsnull. - Example:
Json.set(client, "doc", ".", true).get(); var res = Json.toggle(client, gs("doc")).get(); assert res.equals(false); res = Json.toggle(client, gs("doc")).get(); assert res.equals(true);
-
toggle
public static java.util.concurrent.CompletableFuture<java.lang.Object> toggle(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Toggles a Boolean value stored at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns aBoolean[]with the toggled boolean value for every possible path, ornullfor JSON values matching the path that are not boolean. - For legacy path (
pathdoesn't start with$):
Returns the value of the toggled boolean inpath. Ifpathdoesn't exist or the value atpathisn't a boolean, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"bool\": true, \"nested\": {\"bool\": false, \"nested\": {\"bool\": 10}}}").get(); var res = Json.toggle(client, "doc", "$..bool").get(); assert Arrays.equals((Boolean[]) res, new Boolean[] {false, true, null}); res = Json.toggle(client, "doc", "bool").get(); assert res.equals(true); var getResult = Json.get(client, "doc", "$").get(); assert getResult.equals("{\"bool\": true, \"nested\": {\"bool\": true, \"nested\": {\"bool\": 10}}}");
-
toggle
public static java.util.concurrent.CompletableFuture<java.lang.Object> toggle(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Toggles a Boolean value stored at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns aBoolean[]with the toggled boolean value for every possible path, ornullfor JSON values matching the path that are not boolean. - For legacy path (
pathdoesn't start with$):
Returns the value of the toggled boolean inpath. Ifpathdoesn't exist or the value atpathisn't a boolean, an error is raised.
keydoesn't exist, returnsnull.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"bool\": true, \"nested\": {\"bool\": false, \"nested\": {\"bool\": 10}}}").get(); var res = Json.toggle(client, gs("doc"), gs("$..bool")).get(); assert Arrays.equals((Boolean[]) res, new Boolean[] {false, true, null}); res = Json.toggle(client, gs("doc"), gs("bool")).get(); assert res.equals(true); var getResult = Json.get(client, "doc", "$").get(); assert getResult.equals("{\"bool\": true, \"nested\": {\"bool\": true, \"nested\": {\"bool\": 10}}}");
-
strappend
public static java.util.concurrent.CompletableFuture<java.lang.Object> strappend(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String value, @NonNull @NonNull java.lang.String path)Appends the specifiedvalueto the string stored at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.value- The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns a list of integer replies for every possible path, indicating the length of the resulting string after appendingvalue, ornullfor JSON values matching the path that are not string.
Ifkeydoesn't exist, an error is raised. - For legacy path (
pathdoesn't start with$):
Returns the length of the resulting string after appendingvalueto the string atpath.
If multiple paths match, the length of the last updated string is returned.
If the JSON value atpathis not a string of ifpathdoesn't exist, an error is raised.
Ifkeydoesn't exist, an error is raised.
- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\":\"foo\", \"nested\": {\"a\": \"hello\"}, \"nested2\": {\"a\": 31}}").get(); var res = Json.strappend(client, "doc", "baz", "$..a").get(); assert Arrays.equals((Object[]) res, new Object[] {6L, 8L, null}); // The new length of the string values at path '$..a' in the key stored at `doc` after the append operation. res = Json.strappend(client, "doc", '"foo"', "nested.a").get(); assert (Long) res == 11L; // The length of the string value after appending "foo" to the string at path 'nested.array' in the key stored at `doc`. var getResult = Json.get(client, "doc", "$").get(); assert getResult.equals("[{\"a\":\"foobaz\", \"nested\": {\"a\": \"hellobazfoo\"}, \"nested2\": {\"a\": 31}}]"); // The updated JSON value in the key stored at `doc`.
-
strappend
public static java.util.concurrent.CompletableFuture<java.lang.Object> strappend(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString value, @NonNull @NonNull GlideString path)Appends the specifiedvalueto the string stored at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.value- The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns a list of integer replies for every possible path, indicating the length of the resulting string after appendingvalue, ornullfor JSON values matching the path that are not string.
Ifkeydoesn't exist, an error is raised. - For legacy path (
pathdoesn't start with$):
Returns the length of the resulting string after appendingvalueto the string atpath.
If multiple paths match, the length of the last updated string is returned.
If the JSON value atpathis not a string of ifpathdoesn't exist, an error is raised.
Ifkeydoesn't exist, an error is raised.
- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\":\"foo\", \"nested\": {\"a\": \"hello\"}, \"nested2\": {\"a\": 31}}").get(); var res = Json.strappend(client, gs("doc"), gs("baz"), gs("$..a")).get(); assert Arrays.equals((Object[]) res, new Object[] {6L, 8L, null}); // The new length of the string values at path '$..a' in the key stored at `doc` after the append operation. res = Json.strappend(client, gs("doc"), gs("'\"foo\"'"), gs("nested.a")).get(); assert (Long) res == 11L; // The length of the string value after appending "foo" to the string at path 'nested.array' in the key stored at `doc`. var getResult = Json.get(client, gs("doc"), gs("$")).get(); assert getResult.equals("[{\"a\":\"foobaz\", \"nested\": {\"a\": \"hellobazfoo\"}, \"nested2\": {\"a\": 31}}]"); // The updated JSON value in the key stored at `doc`.
-
strappend
public static java.util.concurrent.CompletableFuture<java.lang.Long> strappend(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String value)Appends the specifiedvalueto the string stored at the root within the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.value- The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.- Returns:
- Returns the length of the resulting string after appending
valueto the string at the root.
If the JSON value at root is not a string, an error is raised.
Ifkeydoesn't exist, an error is raised. - Example:
Json.set(client, "doc", "$", "'\"foo\"'").get(); var res = Json.strappend(client, "doc", "'\"baz\"'").get(); assert res == 6L; // The length of the string value after appending "foo" to the string at root in the key stored at `doc`. var getResult = Json.get(client, "doc").get(); assert getResult.equals("\"foobaz\""); // The updated JSON value in the key stored at `doc`.
-
strappend
public static java.util.concurrent.CompletableFuture<java.lang.Long> strappend(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString value)Appends the specifiedvalueto the string stored at the root within the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.value- The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.- Returns:
- Returns the length of the resulting string after appending
valueto the string at the root.
If the JSON value at root is not a string, an error is raised.
Ifkeydoesn't exist, an error is raised. - Example:
Json.set(client, "doc", "$", "'\"foo\"'").get(); var res = Json.strappend(client, gs("doc"), gs("'\"baz\"'")).get(); assert res == 6L; // The length of the string value after appending "foo" to the string at root in the key stored at `doc`. var getResult = Json.get(client, gs("$"), gs("doc")).get(); assert getResult.equals("\"foobaz\""); // The updated JSON value in the key stored at `doc`.
-
strlen
public static java.util.concurrent.CompletableFuture<java.lang.Object> strlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Returns the length of the JSON string value stored at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns a list of integer replies for every possible path, indicating the length of the JSON string value, ornullfor JSON values matching the path that are not string. - For legacy path (
pathdoesn't start with$):
Returns the length of the JSON value atpathornullifkeydoesn't exist.
If multiple paths match, the length of the first matched string is returned.
If the JSON value atpathis not a string of ifpathdoesn't exist, an error is raised. Ifkeydoesn't exist,nullis returned.
- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\":\"foo\", \"nested\": {\"a\": \"hello\"}, \"nested2\": {\"a\": 31}}").get(); var res = Json.strlen(client, "doc", "$..a").get(); assert Arrays.equals((Object[]) res, new Object[] {3L, 5L, null}); // The length of the string values at path '$..a' in the key stored at `doc`. res = Json.strlen(client, "doc", "nested.a").get(); assert (Long) res == 5L; // The length of the JSON value at path 'nested.a' in the key stored at `doc`. res = Json.strlen(client, "doc", "$").get(); assert Arrays.equals((Object[]) res, new Object[] {null}); // Returns an array with null since the value at root path does in the JSON document stored at `doc` is not a string. res = Json.strlen(client, "non_existing_key", ".").get(); assert res == null; // `key` doesn't exist.
-
strlen
public static java.util.concurrent.CompletableFuture<java.lang.Object> strlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Returns the length of the JSON string value stored at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$):
Returns a list of integer replies for every possible path, indicating the length of the JSON string value, ornullfor JSON values matching the path that are not string. - For legacy path (
pathdoesn't start with$):
Returns the length of the JSON value atpathornullifkeydoesn't exist.
If multiple paths match, the length of the first matched string is returned.
If the JSON value atpathis not a string of ifpathdoesn't exist, an error is raised. Ifkeydoesn't exist,nullis returned.
- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\":\"foo\", \"nested\": {\"a\": \"hello\"}, \"nested2\": {\"a\": 31}}").get(); var res = Json.strlen(client, gs("doc"), gs("$..a")).get(); assert Arrays.equals((Object[]) res, new Object[] {3L, 5L, null}); // The length of the string values at path '$..a' in the key stored at `doc`. res = Json.strlen(client, gs("doc"), gs("nested.a")).get(); assert (Long) res == 5L; // The length of the JSON value at path 'nested.a' in the key stored at `doc`. res = Json.strlen(client, gs("doc"), gs("$")).get(); assert Arrays.equals((Object[]) res, new Object[] {null}); // Returns an array with null since the value at root path does in the JSON document stored at `doc` is not a string. res = Json.strlen(client, gs("non_existing_key"), gs(".")).get(); assert res == null; // `key` doesn't exist.
-
strlen
public static java.util.concurrent.CompletableFuture<java.lang.Long> strlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Returns the length of the JSON string value stored at the root within the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- Returns the length of the JSON value at the root.
If the JSON value is not a string, an error is raised.
Ifkeydoesn't exist,nullis returned. - Example:
Json.set(client, "doc", "$", "\"Hello\"").get(); var res = Json.strlen(client, "doc").get(); assert res == 5L; // The length of the JSON value at the root in the key stored at `doc`. res = Json.strlen(client, "non_existing_key").get(); assert res == null; // `key` doesn't exist.
-
strlen
public static java.util.concurrent.CompletableFuture<java.lang.Long> strlen(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Returns the length of the JSON string value stored at the root within the JSON document stored atkey.- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
- Returns the length of the JSON value at the root.
If the JSON value is not a string, an error is raised.
Ifkeydoesn't exist,nullis returned. - Example:
Json.set(client, "doc", "$", "\"Hello\"").get(); var res = Json.strlen(client, gs("doc")).get(); assert res == 5L; // The length of the JSON value at the root in the key stored at `doc`. res = Json.strlen(client, gs("non_existing_key")).get(); assert res == null; // `key` doesn't exist.
-
clear
public static java.util.concurrent.CompletableFuture<java.lang.Long> clear(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Clears an array and an object at the root of the JSON document stored atkey.
Equivalent toclear(BaseClient, String, String)withpathset to".".- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
1if the document wasn't empty or0if it was.
Ifkeydoesn't exist, an error is raised.- Example:
Json.set(client, "doc", "$", "{\"a\":1, \"b\":2}").get(); long res = Json.clear(client, "doc").get(); assert res == 1; var doc = Json.get(client, "doc", "$").get(); assert doc.equals("[{}]"); res = Json.clear(client, "doc").get(); assert res == 0; // the doc is already empty
-
clear
public static java.util.concurrent.CompletableFuture<java.lang.Long> clear(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Clears an array and an object at the root of the JSON document stored atkey.
Equivalent toclear(BaseClient, GlideString, GlideString)withpathset to".".- Parameters:
client- The client to execute the command.key- The key of the JSON document.- Returns:
1if the document wasn't empty or0if it was.
Ifkeydoesn't exist, an error is raised.- Example:
Json.set(client, "doc", "$", "{\"a\":1, \"b\":2}").get(); long res = Json.clear(client, gs("doc")).get(); assert res == 1; var doc = Json.get(client, "doc", "$").get(); assert doc.equals("[{}]"); res = Json.clear(client, gs("doc")).get(); assert res == 0; // the doc is already empty
-
clear
public static java.util.concurrent.CompletableFuture<java.lang.Long> clear(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Clears arrays and objects at the specifiedpathwithin the JSON document stored atkey.
Numeric values are set to0, boolean values are set tofalse, and string values are converted to empty strings.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- The number of containers cleared.
Ifpathdoesn't exist, or the value atpathis already cleared (e.g., an empty array, object, or string), 0 is returned. Ifkeydoesn't exist, an error is raised. - Example:
Json.set(client, "doc", "$", "{\"obj\": {\"a\":1, \"b\":2}, \"arr\":[1, 2, 3], \"str\": \"foo\", \"bool\": true, \"int\": 42, \"float\": 3.14, \"nullVal\": null}").get(); long res = Json.clear(client, "doc", "$.*").get(); assert res == 6; // 6 values are cleared: "obj", "arr", "str", "bool", "int", and "float"; "nullVal" is not clearable. var doc = Json.get(client, "doc", "$").get(); assert doc.equals("[{\"obj\":{},\"arr\":[],\"str\":\"\",\"bool\":false,\"int\":0,\"float\":0.0,\"nullVal\":null}]"); res = Json.clear(client, "doc", "$.*").get(); assert res == 0; // containers are already empty and nothing is cleared
-
clear
public static java.util.concurrent.CompletableFuture<java.lang.Long> clear(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Clears arrays and objects at the specifiedpathwithin the JSON document stored atkey.
Numeric values are set to0, boolean values are set tofalse, and string values are converted to empty strings.- Parameters:
client- The client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- The number of containers cleared.
Ifpathdoesn't exist, or the value atpathis already cleared (e.g., an empty array, object, or string), 0 is returned. Ifkeydoesn't exist, an error is raised. - Example:
Json.set(client, "doc", "$", "{\"obj\": {\"a\":1, \"b\":2}, \"arr\":[1, 2, 3], \"str\": \"foo\", \"bool\": true, \"int\": 42, \"float\": 3.14, \"nullVal\": null}").get(); long res = Json.clear(client, gs("doc"), gs("$.*")).get(); assert res == 6; // 6 values are cleared: "obj", "arr", "str", "bool", "int", and "float"; "nullVal" is not clearable. var doc = Json.get(client, "doc", "$").get(); assert doc.equals("[{\"obj\":{},\"arr\":[],\"str\":\"\",\"bool\":false,\"int\":0,\"float\":0.0,\"nullVal\":null}]"); res = Json.clear(client, gs("doc"), gs("$.*")).get(); assert res == 0; // containers are already empty and nothing is cleared
-
resp
public static java.util.concurrent.CompletableFuture<java.lang.Object> resp(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Retrieves the JSON document stored atkey. The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).- JSON null is mapped to the RESP Null Bulk String.
- JSON Booleans are mapped to RESP Simple string.
- JSON integers are mapped to RESP Integers.
- JSON doubles are mapped to RESP Bulk Strings.
- JSON strings are mapped to RESP Bulk Strings.
- JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.
- JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.
- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.- Returns:
- Returns the JSON document in its RESP form.
If
keydoesn't exist,nullis returned. - Example:
{@code Json.set(client, "doc", ".", "{\"a\": [1, 2, 3], \"b\": {\"b1\": 1}, \"c\": 42}"); Object actualResult = Json.resp(client, "doc").get(); Object[] expectedResult = new Object[] { "{", new Object[] {"a", new Object[] {"[", 1L, 2L, 3L}}, new Object[] {"b", new Object[] {"{", new Object[] {"b1", 1L}}}, new Object[] {"c", 42L} }; assertInstanceOf(Object[].class, actualResult); assertArrayEquals(expectedResult, (Object[]) actualResult); }
-
resp
public static java.util.concurrent.CompletableFuture<java.lang.Object> resp(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Retrieves the JSON document stored atkey. The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).- JSON null is mapped to the RESP Null Bulk String.
- JSON Booleans are mapped to RESP Simple string.
- JSON integers are mapped to RESP Integers.
- JSON doubles are mapped to RESP Bulk Strings.
- JSON strings are mapped to RESP Bulk Strings.
- JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.
- JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.
- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.- Returns:
- Returns the JSON document in its RESP form.
If
keydoesn't exist,nullis returned. - Example:
{@code Json.set(client, "doc", ".", "{\"a\": [1, 2, 3], \"b\": {\"b1\": 1}, \"c\": 42}"); Object actualResultBinary = Json.resp(client, gs("doc")).get(); Object[] expectedResultBinary = new Object[] { "{", new Object[] {gs("a"), new Object[] {gs("["), 1L, 2L, 3L}}, new Object[] {gs("b"), new Object[] {gs("{"), new Object[] {gs("b1"), 1L}}}, new Object[] {gs("c"), 42L} }; assertInstanceOf(Object[].class, actualResultBinary); assertArrayEquals(expectedResultBinary, (Object[]) actualResultBinary); }
-
resp
public static java.util.concurrent.CompletableFuture<java.lang.Object> resp(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Retrieve the JSON value at the specifiedpathwithin the JSON document stored atkey. The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).- JSON null is mapped to the RESP Null Bulk String.
- JSON Booleans are mapped to RESP Simple string.
- JSON integers are mapped to RESP Integers.
- JSON doubles are mapped to RESP Bulk Strings.
- JSON strings are mapped to RESP Bulk Strings.
- JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.
- JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.
- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$): Returns a list of replies for every possible path, indicating the RESP form of the JSON value. Ifpathdoesn't exist, returns an empty list. - For legacy path (
pathdoesn'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. Ifpathdoesn't exist, an error is raised.
keydoesn't exist,nullis returned.- For JSONPath (
- Example:
Json.set(client, "doc", ".", "{\"a\": [1, 2, 3], \"b\": {\"a\": [1, 2], \"c\": {\"a\": 42}}}"); Object actualResult = Json.resp(client, "doc", "$..a").get(); // JSONPath returns all possible paths Object[] expectedResult = new Object[] { new Object[] {"[", 1L, 2L, 3L}, new Object[] {"[", 1L, 2L}, 42L}; assertArrayEquals(expectedResult, (Object[]) actualResult); // legacy path only returns the first JSON value match assertArrayEquals(new Object[] {"[", 1L, 2L, 3L}, (Object[]) Json.resp(client, key, "..a").get());
-
resp
public static java.util.concurrent.CompletableFuture<java.lang.Object> resp(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Retrieve the JSON value at the specifiedpathwithin the JSON document stored atkey. The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).- JSON null is mapped to the RESP Null Bulk String.
- JSON Booleans are mapped to RESP Simple string.
- JSON integers are mapped to RESP Integers.
- JSON doubles are mapped to RESP Bulk Strings.
- JSON strings are mapped to RESP Bulk Strings.
- JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.
- JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.
- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.path- The path within the JSON document.- Returns:
- For JSONPath (
pathstarts with$): Returns a list of replies for every possible path, indicating the RESP form of the JSON value. Ifpathdoesn't exist, returns an empty list. - For legacy path (
pathdoesn'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. Ifpathdoesn't exist, an error is raised.
keydoesn't exist,nullis returned.- For JSONPath (
- Example:
Json.set(client, "doc", ".", "{\"a\": [1, 2, 3], \"b\": {\"a\": [1, 2], \"c\": {\"a\": 42}}}"); Object actualResult = Json.resp(client, gs("doc"), gs("$..a")).get(); // JSONPath returns all possible paths Object[] expectedResult = new Object[] { new Object[] {gs("["), 1L, 2L, 3L}, new Object[] {gs("["), 1L, 2L}, 42L}; assertArrayEquals(expectedResult, (Object[]) actualResult); // legacy path only returns the first JSON value match assertArrayEquals(new Object[] {gs("["), 1L, 2L, 3L}, (Object[]) Json.resp(client, gs(key), gs("..a")).get());
-
type
public static java.util.concurrent.CompletableFuture<java.lang.Object> type(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key)Retrieves the type of the JSON value at the root of the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.- Returns:
- Returns the type of the JSON value at root. If
keydoesn't exist,nullis returned. - Example:
Json.set(client, "doc", "$", "[1, 2, 3]"); assertEquals("array", Json.type(client, "doc").get()); Json.set(client, "doc", "$", "{\"a\": 1}"); assertEquals("object", Json.type(client, "doc").get()); assertNull(Json.type(client, "non_existing_key").get());
-
type
public static java.util.concurrent.CompletableFuture<java.lang.Object> type(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key)Retrieves the type of the JSON value at the root of the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.- Returns:
- Returns the type of the JSON value at root. If
keydoesn't exist,nullis returned. - Example:
Json.set(client, "doc", "$", "[1, 2, 3]"); assertEquals(gs("array"), Json.type(client, gs("doc")).get()); Json.set(client, "doc", "$", "{\"a\": 1}"); assertEquals(gs("object"), Json.type(client, gs("doc")).get()); assertNull(Json.type(client, gs("non_existing_key")).get());
-
type
public static java.util.concurrent.CompletableFuture<java.lang.Object> type(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String path)Retrieves the type of the JSON value at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.path- Represents the path within the JSON document where the type will be retrieved.- Returns:
- For JSONPath (
pathstarts 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. - For legacy path (
pathdoesn'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,nullwill be returned.
keydoesn't exist,nullis returned.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); assertArrayEquals(new Object[]{"object"}, (Object[]) Json.type(client, key, "$.nested").get()); assertArrayEquals(new Object[]{"integer"}, (Object[]) Json.type(client, key, "$.nested.a").get()); assertArrayEquals(new Object[]{"integer", "object"}, (Object[]) Json.type(client, key, "$[*]").get());
-
type
public static java.util.concurrent.CompletableFuture<java.lang.Object> type(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString key, @NonNull @NonNull GlideString path)Retrieves the type of the JSON value at the specifiedpathwithin the JSON document stored atkey.- Parameters:
client- The Valkey GLIDE client to execute the command.key- The key of the JSON document.path- Represents the path within the JSON document where the type will be retrieved.- Returns:
- For JSONPath (
pathstarts 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. - For legacy path (
pathdoesn'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,nullwill be returned.
keydoesn't exist,nullis returned.- For JSONPath (
- Example:
Json.set(client, "doc", "$", "{\"a\": 1, \"nested\": {\"a\": 2, \"b\": 3}}"); assertArrayEquals(new Object[]{gs("object")}, (Object[]) Json.type(client, gs(key), gs("$.nested")).get()); assertArrayEquals(new Object[]{gs("integer")}, (Object[]) Json.type(client, gs(key), gs("$.nested.a")).get()); assertArrayEquals(new Object[]{gs("integer"), gs("object")}, (Object[]) Json.type(client, gs(key), gs("$[*]")).get());
-
-