Interface RedisJsonSerializer.Splitter
- All Superinterfaces:
RedisJsonSerializer, RedisSerializer<Object>
- All Known Implementing Classes:
GenericJackson2JsonRedisSerializer, GenericJacksonJsonRedisSerializer
- Enclosing interface:
RedisJsonSerializer
- Since:
- 4.2
- Author:
- Moritz Halbritter
-
Nested Class Summary
Nested classes/interfaces inherited from interface RedisJsonSerializer
RedisJsonSerializer.Splitter -
Method Summary
Modifier and TypeMethodDescriptiondefault byte[]joinObject(Map<String, byte[]> members) Create a JSON object from the given members.default List<byte[]> splitArray(byte[] source) Extract immediate elements of a JSON array as individual JSON values.splitObject(byte[] source) Extract the immediate members of a JSON object as individual JSON values.Methods inherited from interface RedisJsonSerializer
deserialize, deserialize, splitterMethods inherited from interface RedisSerializer
canSerialize, deserialize, deserialize, getTargetType, serialize
-
Method Details
-
splitArray
Extract immediate elements of a JSON array as individual JSON values.Note: The default implementation deserializes the array and serializes each element separately. This may change number formatting or precision. For example,
1.10may become1.1. Implementations should override this method to preserve the original bytes of each element.- Parameters:
source- the JSON array to read.- Returns:
- the JSON bytes for each element in array order, or an empty list if the array is empty.
- Throws:
SerializationException- if the source is not a JSON array or cannot be read.
-
splitObject
Extract the immediate members of a JSON object as individual JSON values.Note: Map keys contain the unescaped member names. Values contain the JSON bytes for each member. The default implementation deserializes the object and serializes each member value separately. See
splitArray(byte[])for the effect on number formatting and precision.- Parameters:
source- the JSON object to read.- Returns:
- the members in source order, or an empty map if the object is empty.
- Throws:
SerializationException- if the source is not a JSON object or cannot be read.
-
joinObject
Create a JSON object from the given members.Map keys supply the member names, which are escaped as needed. Each value must contain a valid JSON value. Members are written in map iteration order.
Note: The default implementation deserializes the member values and serializes the resulting object. See
splitArray(byte[])for the effect on number formatting and precision. Implementations can override this method to preserve the supplied JSON bytes for each value.- Parameters:
members- the member names and their JSON bytes.- Returns:
- the JSON object as bytes, or the representation of
{}if the map is empty. - Throws:
SerializationException- if the object cannot be written.- See Also:
-