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(byte[] bytes,
Type type,
SerializerEncoding encoding)
Deserializes a byte array into an object.
|
<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 stream into an object.
|
<T> T |
deserialize(String value,
Type type,
SerializerEncoding encoding)
Deserializes a string into an 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.
|
ObjectMapper |
serializer() |
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 ObjectMapper |
simpleMapper()
Gets a static instance of
ObjectMapper that doesn't handle flattening. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
serializeIterable
public JacksonAdapter()
protected ObjectMapper simpleMapper()
ObjectMapper
that doesn't handle flattening.ObjectMapper
.public static SerializerAdapter createDefaultSerializerAdapter()
public ObjectMapper serializer()
public String serialize(Object object, SerializerEncoding encoding) throws IOException
SerializerAdapter
serialize
in interface SerializerAdapter
object
- The object to serialize.encoding
- The serialization encoding.IOException
- If an IO exception was thrown during serialization.public byte[] serializeToBytes(Object object, SerializerEncoding encoding) throws IOException
SerializerAdapter
serializeToBytes
in interface SerializerAdapter
object
- The object to serialize.encoding
- The serialization encoding.IOException
- If an IO exception was thrown during serialization.public void serialize(Object object, SerializerEncoding encoding, OutputStream outputStream) throws IOException
SerializerAdapter
OutputStream
.serialize
in interface SerializerAdapter
object
- The object to serialize.encoding
- The serialization encoding.outputStream
- The OutputStream
where the serialized object will be written.IOException
- If an IO exception was thrown during serialization.public String serializeRaw(Object object)
SerializerAdapter
serializeRaw
in interface SerializerAdapter
object
- The object to serialize.public String serializeList(List<?> list, CollectionFormat format)
SerializerAdapter
serializeList
in interface SerializerAdapter
list
- The list to serialize.format
- The collection joining format.public <T> T deserialize(String value, Type type, SerializerEncoding encoding) throws IOException
SerializerAdapter
deserialize
in interface SerializerAdapter
T
- The type of the deserialized object.value
- The string to deserialize.type
- The type of the deserialized object.encoding
- The deserialization encoding.IOException
- If an IO exception was thrown during deserialization.public <T> T deserialize(byte[] bytes, Type type, SerializerEncoding encoding) throws IOException
SerializerAdapter
deserialize
in interface SerializerAdapter
T
- The type of the deserialized object.bytes
- The byte array to deserialize.type
- The type of the deserialized object.encoding
- The deserialization encoding.IOException
- If an IO exception was thrown during serialization.public <T> T deserialize(InputStream inputStream, Type type, SerializerEncoding encoding) throws IOException
SerializerAdapter
deserialize
in interface SerializerAdapter
T
- The type of the deserialized object.inputStream
- The InputStream
to deserialize.type
- The type of the deserialized object.encoding
- The deserialization encoding.IOException
- If an IO exception was thrown during serialization.public <T> T deserialize(HttpHeaders headers, Type deserializedHeadersType) throws IOException
SerializerAdapter
'Matching' headers are the REST API returned headers those with:
HeaderCollection
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 SerializerAdapter
T
- 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 © 2021 Microsoft Corporation. All rights reserved.