public class JacksonAdapter extends Object implements SerializerAdapter
SerializerAdapter for Jackson.| Constructor and Description |
|---|
JacksonAdapter()
Creates a new JacksonAdapter instance with default mapper settings.
|
| Modifier and Type | Method and Description |
|---|---|
static SerializerAdapter |
createDefaultSerializerAdapter()
maintain singleton instance of the default serializer adapter.
|
<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.
|
<T> T |
deserialize(InputStream inputStream,
Type type,
SerializerEncoding encoding)
Deserializes a byte[] into a
T object. |
<T> T |
deserialize(String value,
Type type,
SerializerEncoding encoding)
Deserializes a string into a
T object. |
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() |
String |
serializeRaw(Object object)
Serializes an object into a raw string.
|
protected com.fasterxml.jackson.databind.ObjectMapper |
simpleMapper()
Gets a static instance of
ObjectMapper that doesn't handle flattening. |
public JacksonAdapter()
protected com.fasterxml.jackson.databind.ObjectMapper simpleMapper()
ObjectMapper that doesn't handle flattening.ObjectMapper.public static SerializerAdapter createDefaultSerializerAdapter()
public com.fasterxml.jackson.databind.ObjectMapper serializer()
public String serialize(Object object, SerializerEncoding encoding) throws IOException
SerializerAdapterserialize in interface SerializerAdapterobject - the object to serializeencoding - the encoding to use for serializationIOException - exception from serializationpublic void serialize(Object object, SerializerEncoding encoding, OutputStream outputStream) throws IOException
SerializerAdapterOutputStream.serialize in interface SerializerAdapterobject - The object to serialize.encoding - The encoding to use for serialization.outputStream - The OutputStream where the serialized object will be written.IOException - exception from serializationpublic String serializeRaw(Object object)
SerializerAdapterserializeRaw in interface SerializerAdapterobject - the object to serializepublic String serializeList(List<?> list, CollectionFormat format)
SerializerAdapterserializeList in interface SerializerAdapterlist - the list to serializeformat - the Swagger collection formatpublic <T> T deserialize(String value, Type type, SerializerEncoding encoding) throws IOException
SerializerAdapterT object.deserialize in interface SerializerAdapterT - the type of the deserialized objectvalue - the string value to deserializetype - the type to deserializeencoding - the encoding used in the serialized valueIOException - exception from deserializationpublic <T> T deserialize(InputStream inputStream, Type type, SerializerEncoding encoding) throws IOException
SerializerAdapterT object.deserialize in interface SerializerAdapterT - The type of the deserialized object.inputStream - The InputStream containing the serialized object data to deserialize.type - The type to deserialize.encoding - The encoding used to serialize value.IOException - exception from deserializationpublic <T> T deserialize(HttpHeaders headers, Type deserializedHeadersType) throws IOException
SerializerAdapterHeaderCollection annotation applied to
the properties in the entity.ResponseBase returned by java proxy method corresponding to the REST API.
e.g.
Mono<RestResponseBase<FooMetadataHeaders, Void>> getMetadata(args);
class FooMetadataHeaders {
String name;
{@literal @}HeaderCollection("header-collection-prefix-")
Map<String,String> headerCollection;
}
in the case of above example, this method produces an instance of FooMetadataHeaders from provided
headers.deserialize in interface SerializerAdapterT - the type of the deserialized objectheaders - the REST API returned headersdeserializedHeadersType - the type to deserializeheaders, if header entity model does not
not exists then return nullIOException - If an I/O error occursCopyright © 2020 Microsoft Corporation. All rights reserved.