Interface JsonOperations.JsonPathResult
- Enclosing interface:
JsonOperations<K>
The as(Class) methods deserialize an object with one property per requested path. Property names
correspond to the path strings supplied to JsonOperations.paths(Object, Collection). Each property's value
is extracted from that path's match array. A path with no matches contributes JSON null. Use
path(String) to access the matches for an individual path.
The raw JSON.GET response contains a match array for a single requested path. For multiple paths, it
contains an object keyed by the JSONPath expressions sent to Redis. Property paths are converted to bracket
notation, so a request for "name" uses "$['name']" as the response key.
- Since:
- 4.2
- Author:
- Mark Paluch, Yordan Tsintsov, Moritz Halbritter
-
Method Summary
Modifier and TypeMethodDescription<V> @Nullable VDeserialize the selected values into an object of the given type.<V> @Nullable Vas(ParameterizedTypeReference<V> type) Deserialize the selected values into an object of the given type.byte @Nullable []asBytes()Return theJSON.GETresponse as raw bytes.asString()Return theJSON.GETresponse as a UTF-8 string.booleanexists()Return whether the key exists.Apply the given function to the rawJSON.GETresponse.Return the result for a requested path.
-
Method Details
-
asBytes
byte @Nullable [] asBytes()Return theJSON.GETresponse as raw bytes.The response retains the match arrays and any JSONPath keys returned by Redis.
- Returns:
- the JSON bytes, or null if the key does not exist.
-
asString
-
map
Apply the given function to the rawJSON.GETresponse.The function receives the same representation as
asBytes(), including the match arrays and any JSONPath keys. It is not invoked if the key does not exist.- Type Parameters:
U- the mapped result type.- Parameters:
mapper- the function to apply to the response bytes.- Returns:
- the function result, or null if the key does not exist.
-
as
Deserialize the selected values into an object of the given type.Each requested path contributes one property as described in
JsonOperations.JsonPathResult. Usepath(String)to access a path with multiple matches.- Type Parameters:
V- the result type.- Parameters:
type- the target type.- Returns:
- the deserialized object, or null if the key does not exist.
- Throws:
SerializationException- if a path has more than one match, or the object cannot be deserialized.
-
as
Deserialize the selected values into an object of the given type.Each requested path contributes one property as described in
JsonOperations.JsonPathResult. Usepath(String)to access a path with multiple matches.- Type Parameters:
V- the result type.- Parameters:
type- the target type.- Returns:
- the deserialized object, or null if the key does not exist.
- Throws:
SerializationException- if a path has more than one match, or the object cannot be deserialized.
-
path
Return the result for a requested path.The result contains the path's match array and supports any number of matches.
- Parameters:
path- the path string supplied toJsonOperations.paths(Object, Collection), must not be null.- Returns:
- the result for the requested path.
- Throws:
IllegalArgumentException- if the path was not requested.
-
exists
boolean exists()Return whether the key exists.An existing key may have no matches for individual paths.
- Returns:
- true if the key exists; false otherwise.
-