Class JacksonAdapter
java.lang.Object
com.azure.core.serializer.json.jackson.JacksonAdapter
- All Implemented Interfaces:
SerializerAdapter
Implementation of
SerializerAdapter that uses Jackson.
This is similar to JacksonAdapter found in the com.azure:azure-core package and will serve as the
long term replacement plan for the JacksonAdapter found in com.azure:azure-core.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SerializerAdaptermaintain singleton instance of the default serializer adapter.<T> Tdeserialize(byte[] bytes, Type type, SerializerEncoding encoding) Deserializes a byte array into an object.<T> Tdeserialize(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> Tdeserialize(InputStream inputStream, Type type, SerializerEncoding encoding) Deserializes a stream into an object.<T> Tdeserialize(String value, Type type, SerializerEncoding encoding) Deserializes a string into an object.<T> TdeserializeHeader(Header header, Type type) Deserializes the provided header returned from a REST API to en entity instance declared as the model of the header.serialize(Object object, SerializerEncoding encoding) Serializes an object into a string.voidserialize(Object object, SerializerEncoding encoding, OutputStream outputStream) Serializes an object and writes its output into anOutputStream.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.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.core.util.serializer.SerializerAdapter
serializeIterable
-
Method Details
-
defaultSerializerAdapter
maintain singleton instance of the default serializer adapter.- Returns:
- the default serializer
-
serialize
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterSerializes an object into a string.- Specified by:
serializein interfaceSerializerAdapter- Parameters:
object- The object to serialize.encoding- The serialization encoding.- Returns:
- The object serialized as a string using the specified encoding. If the object is null, null is returned.
- Throws:
IOException- If an IO exception was thrown during serialization.
-
serializeToBytes
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterSerializes an object into a byte array.- Specified by:
serializeToBytesin interfaceSerializerAdapter- Parameters:
object- The object to serialize.encoding- The serialization encoding.- Returns:
- The object serialized as a byte array.
- Throws:
IOException- If an IO exception was thrown during serialization.
-
serialize
public void serialize(Object object, SerializerEncoding encoding, OutputStream outputStream) throws IOException Description copied from interface:com.azure.core.util.serializer.SerializerAdapterSerializes an object and writes its output into anOutputStream.- Specified by:
serializein interfaceSerializerAdapter- Parameters:
object- The object to serialize.encoding- The serialization encoding.outputStream- TheOutputStreamwhere the serialized object will be written.- Throws:
IOException- If an IO exception was thrown during serialization.
-
serializeRaw
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterSerializes an object into a raw string, leading and trailing quotes will be trimmed.- Specified by:
serializeRawin interfaceSerializerAdapter- Parameters:
object- The object to serialize.- Returns:
- The object serialized as a string. If the object is null, null is returned.
-
serializeList
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterSerializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.- Specified by:
serializeListin interfaceSerializerAdapter- Parameters:
list- The list to serialize.format- The collection joining format.- Returns:
- The list serialized as a joined string.
-
deserialize
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterDeserializes a string into an object.- Specified by:
deserializein interfaceSerializerAdapter- Type Parameters:
T- The type of the deserialized object.- Parameters:
value- The string to deserialize.type- The type of the deserialized object.encoding- The deserialization encoding.- Returns:
- The string deserialized into an object.
- Throws:
IOException- If an IO exception was thrown during deserialization.
-
deserialize
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterDeserializes a byte array into an object.- Specified by:
deserializein interfaceSerializerAdapter- Type Parameters:
T- The type of the deserialized object.- Parameters:
bytes- The byte array to deserialize.type- The type of the deserialized object.encoding- The deserialization encoding.- Returns:
- The string deserialized into an object.
- Throws:
IOException- If an IO exception was thrown during serialization.
-
deserialize
public <T> T deserialize(InputStream inputStream, Type type, SerializerEncoding encoding) throws IOException Description copied from interface:com.azure.core.util.serializer.SerializerAdapterDeserializes a stream into an object.- Specified by:
deserializein interfaceSerializerAdapter- Type Parameters:
T- The type of the deserialized object.- Parameters:
inputStream- TheInputStreamto deserialize.type- The type of the deserialized object.encoding- The deserialization encoding.- Returns:
- The stream deserialized into an object.
- Throws:
IOException- If an IO exception was thrown during serialization.
-
deserialize
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterDeserialize 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
HeaderCollectionannotation applied to the properties in the entity.
ResponseBasereturned 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 providedheaders.- Specified by:
deserializein interfaceSerializerAdapter- Type Parameters:
T- the type of the deserialized object- Parameters:
headers- the REST API returned headersdeserializedHeadersType- the type to deserialize- Returns:
- instance of header entity type created based on provided
headers, if header entity model does not exist then return null - Throws:
IOException- If an I/O error occurs
-
deserializeHeader
Description copied from interface:com.azure.core.util.serializer.SerializerAdapterDeserializes the provided header returned from a REST API to en entity instance declared as the model of the header.- Specified by:
deserializeHeaderin interfaceSerializerAdapter- Type Parameters:
T- The type of the deserialized header.- Parameters:
header- The header.type- The type that represents the deserialized header.- Returns:
- A new instance of the type that represents the deserialized header.
- Throws:
IOException- If an I/O error occurs.
-