JacksonAdapter Class
- java.
lang. Object - com.
azure. core. util. serializer. JacksonAdapter
- com.
Implements
public class JacksonAdapter
implements SerializerAdapter
Implementation of SerializerAdapter for Jackson.
Constructor Summary
| Constructor | Description |
|---|---|
| JacksonAdapter() |
Creates a new Jackson |
| JacksonAdapter(BiConsumer<ObjectMapper,ObjectMapper> configureSerialization) |
Deprecated
This API will be removed in the future. Please use createDefaultSerializerAdapter() if you need to use Jackson
Creates a new Jackson |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
static
Serializer |
createDefaultSerializerAdapter()
maintain singleton instance of the default serializer adapter. |
| T |
deserialize(byte[] bytes, Type type, SerializerEncoding encoding)
Deserializes a byte array into an object. |
| T |
deserialize(HttpHeaders headers, Type deserializedHeadersType)
Deserialize the provided headers returned from a REST API to an entity instance declared as the model to hold 'Matching' headers. |
| T |
deserialize(InputStream inputStream, Type type, SerializerEncoding encoding)
Deserializes a stream into an object. |
| T |
deserialize(String value, Type type, SerializerEncoding encoding)
Deserializes a string into an object. |
| T |
deserializeHeader(Header header, Type type)
Deserializes the provided header returned from a REST API to en entity instance declared as the model of the header. |
| String |
serialize(Object object, SerializerEncoding encoding)
Serializes an object into a string. |
| void |
serialize(Object object, SerializerEncoding encoding, OutputStream outputStream)
Serializes an object and writes its output into an OutputStream. |
| String |
serializeList(List<?> list, CollectionFormat format)
Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list. |
| com.fasterxml.jackson.databind.ObjectMapper |
serializer()
Deprecated
deprecated to avoid direct ObjectMapper usage in favor of using more resilient and debuggable JacksonAdapter APIs.
|
| String |
serializeRaw(Object object)
Serializes an object into a raw string, leading and trailing quotes will be trimmed. |
| byte[] |
serializeToBytes(Object object, SerializerEncoding encoding)
Serializes an object into a byte array. |
| protected com.fasterxml.jackson.databind.ObjectMapper |
simpleMapper()
Deprecated
deprecated, use
JacksonAdapter(BiConsumer ) constructor to configure modules.
Gets a static instance of ObjectMapper that doesn't handle flattening. |
Methods inherited from java.lang.Object
Constructor Details
JacksonAdapter
public JacksonAdapter()
Creates a new JacksonAdapter instance with default mapper settings.
JacksonAdapter
@Deprecated
public JacksonAdapter(BiConsumer<ObjectMapper,ObjectMapper> configureSerialization)
Deprecated
Creates a new JacksonAdapter instance with Azure Core mapper settings and applies additional configuration through configureSerialization callback.
configureSerialization callback provides outer and inner instances of ObjectMapper. Both of them are pre-configured for Azure serialization needs, but only outer mapper capable of flattening and populating additionalProperties. Outer mapper is used by JacksonAdapter for all serialization needs.
Register modules on the outer instance to add custom (de)serializers similar to new JacksonAdapter((outer, inner) -> outer.registerModule(new MyModule())) Use inner mapper for chaining serialization logic in your (de)serializers.
Parameters:
Method Details
createDefaultSerializerAdapter
public static SerializerAdapter createDefaultSerializerAdapter()
maintain singleton instance of the default serializer adapter.
Returns:
deserialize
public T <T>deserialize(byte[] bytes, Type type, SerializerEncoding encoding)
Deserializes a byte array into an object.
Parameters:
Throws:
deserialize
public T <T>deserialize(HttpHeaders headers, Type deserializedHeadersType)
Deserialize the provided headers returned from a REST API to an entity instance declared as the model to hold 'Matching' headers.
'Matching' headers are the REST API returned headers those with:
- header names same as name of a properties in the entity.
- header names start with value of HeaderCollection annotation applied to the properties in the entity.
When needed, the 'header entity' types must be declared as first generic argument of ResponseBase<H,T> returned by java proxy method corresponding to the REST API. e.g. Mono> getMetadata(args); class FooMetadataHeaders { String name; {@literal @}HeaderCollection("header-collection-prefix-") Map headerCollection; } in the case of above example, this method produces an instance of FooMetadataHeaders from provided headers.
Parameters:
Throws:
deserialize
public T <T>deserialize(InputStream inputStream, Type type, SerializerEncoding encoding)
Deserializes a stream into an object.
Parameters:
Throws:
deserialize
public T <T>deserialize(String value, Type type, SerializerEncoding encoding)
Deserializes a string into an object.
Parameters:
Throws:
deserializeHeader
public T <T>deserializeHeader(Header header, Type type)
Deserializes the provided header returned from a REST API to en entity instance declared as the model of the header.
Parameters:
Throws:
serialize
public String serialize(Object object, SerializerEncoding encoding)
Serializes an object into a string.
Parameters:
Throws:
serialize
public void serialize(Object object, SerializerEncoding encoding, OutputStream outputStream)
Serializes an object and writes its output into an OutputStream.
Parameters:
Throws:
serializeList
public String serializeList(List<?> list, CollectionFormat format)
Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.
Parameters:
serializer
@Deprecated
public ObjectMapper serializer()
Deprecated
Returns:
serializeRaw
public String serializeRaw(Object object)
Serializes an object into a raw string, leading and trailing quotes will be trimmed.
Parameters:
serializeToBytes
public byte[] serializeToBytes(Object object, SerializerEncoding encoding)
Serializes an object into a byte array.
Parameters:
Throws:
simpleMapper
@Deprecated
protected ObjectMapper simpleMapper()
Deprecated
JacksonAdapter(BiConsumer ) constructor to configure modules.
Gets a static instance of ObjectMapper that doesn't handle flattening.
Returns: