Package com.couchbase.client.java.codec
Class Jackson3JsonSerializer
java.lang.Object
com.couchbase.client.java.codec.Jackson3JsonSerializer
- All Implemented Interfaces:
JsonSerializer
A serializer backed by a user-provided Jackson 3
JsonMapper.
In order to use this class, you must add Jackson 3 to your class path.
Example usage:
var mapper = JsonMapper.builder().build();
var serializer = Jackson3JsonSerializer.create(mapper);
// Set as default serializer when connecting
Cluster cluster = Cluster.connect(
connectionString,
ClusterOptions.clusterOptions(username, password)
.environment(env -> env
.jsonSerializer(serializer)
)
);
WARNING: This serializer ignores the Encrypted
annotation for automatic Field-Level Encryption (FLE). Automatic FLE with data binding requires using
JacksonJsonSerializer and Jackson 2, or the default serializer which uses a repackaged version of Jackson 2.-
Method Summary
Modifier and TypeMethodDescriptionstatic Jackson3JsonSerializercreate(tools.jackson.databind.json.JsonMapper mapper) Returns a new instance backed by the given mapper.<T> Tdeserialize(TypeRef<T> target, byte[] input) Deserializes raw input into the target type.<T> Tdeserialize(Class<T> target, byte[] input) Deserializes raw input into the target class.byte[]Serializes the given input into its encoded byte array form.
-
Method Details
-
create
Returns a new instance backed by the given mapper.- Parameters:
mapper- the custom JsonMapper to use.
-
serialize
Description copied from interface:JsonSerializerSerializes the given input into its encoded byte array form.- Specified by:
serializein interfaceJsonSerializer- Parameters:
input- the object as input.- Returns:
- the serialized output.
-
deserialize
Description copied from interface:JsonSerializerDeserializes raw input into the target class.- Specified by:
deserializein interfaceJsonSerializer- Type Parameters:
T- the generic type to deserialize into.- Parameters:
target- the target class.input- the raw input.- Returns:
- the deserialized output.
-
deserialize
Description copied from interface:JsonSerializerDeserializes raw input into the target type.- Specified by:
deserializein interfaceJsonSerializer- Type Parameters:
T- the type to deserialize into.- Parameters:
target- the target type.input- the raw input.- Returns:
- the deserialized output.
-