Class JacksonSerder
- java.lang.Object
-
- com.azure.android.core.serde.jackson.JacksonSerder
-
public final class JacksonSerder extends java.lang.Object
The type exposes APIs for serialization and deserialization using Jackson.
-
-
Constructor Summary
Constructors Constructor Description JacksonSerder()
Creates a new JacksonAdapter instance with default mapper settings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JacksonSerder
createDefault()
maintain singleton instance of the default serializer adapter.<T> T
deserialize(java.io.InputStream inputStream, java.lang.reflect.Type type, SerdeEncoding encoding)
Deserializes a byte[] into aT
object.<T> T
deserialize(java.lang.String value, java.lang.reflect.Type type, SerdeEncoding encoding)
Deserializes a string into aT
object.<T> T
deserialize(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.reflect.Type deserializedHeadersType)
Deserialize the provided headers returned from a REST API to an entity instance declared as the model to hold 'Matching' headers.java.lang.String
serialize(java.lang.Object object, SerdeEncoding encoding)
Serializes an object into a string.void
serialize(java.lang.Object object, SerdeEncoding encoding, java.io.OutputStream outputStream)
Serializes an object and writes its output into anOutputStream
.java.lang.String
serializeList(java.util.List<?> list, SerdeCollectionFormat format)
Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.java.lang.String
serializeRaw(java.lang.Object object)
Serializes an object into a raw string.
-
-
-
Method Detail
-
createDefault
public static JacksonSerder createDefault()
maintain singleton instance of the default serializer adapter.- Returns:
- the default serializer
-
serialize
public java.lang.String serialize(java.lang.Object object, SerdeEncoding encoding) throws java.io.IOException
Serializes an object into a string.- Parameters:
object
- the object to serializeencoding
- the encoding to use for serialization- Returns:
- the serialized string. Null if the object to serialize is null
- Throws:
java.io.IOException
- exception from serialization
-
serialize
public void serialize(java.lang.Object object, SerdeEncoding encoding, java.io.OutputStream outputStream) throws java.io.IOException
Serializes an object and writes its output into anOutputStream
.- Parameters:
object
- The object to serialize.encoding
- The encoding to use for serialization.outputStream
- TheOutputStream
where the serialized object will be written.- Throws:
java.io.IOException
- exception from serialization
-
serializeRaw
public java.lang.String serializeRaw(java.lang.Object object)
Serializes an object into a raw string. The leading and trailing quotes will be trimmed.- Parameters:
object
- the object to serialize- Returns:
- the serialized string. Null if the object to serialize is null
-
serializeList
public java.lang.String serializeList(java.util.List<?> list, SerdeCollectionFormat 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:
list
- the list to serializeformat
- the Swagger collection format- Returns:
- the serialized string
-
deserialize
public <T> T deserialize(java.lang.String value, java.lang.reflect.Type type, SerdeEncoding encoding) throws java.io.IOException
Deserializes a string into aT
object.- Type Parameters:
T
- the type of the deserialized object- Parameters:
value
- the string value to deserializetype
- the type to deserializeencoding
- the encoding used in the serialized value- Returns:
- the deserialized object
- Throws:
java.io.IOException
- exception from reading value to deserializeSerdeParseException
- exception from deserialization
-
deserialize
public <T> T deserialize(java.io.InputStream inputStream, java.lang.reflect.Type type, SerdeEncoding encoding) throws java.io.IOException
Deserializes a byte[] into aT
object.- Type Parameters:
T
- The type of the deserialized object.- Parameters:
inputStream
- TheInputStream
containing the serialized object data to deserialize.type
- The type to deserialize.encoding
- The encoding used to serialize value.- Returns:
- The deserialized object, or null if it cannot be deserialized.
- Throws:
java.io.IOException
- exception from deserializationSerdeParseException
- exception from deserialization
-
deserialize
public <T> T deserialize(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.reflect.Type deserializedHeadersType) throws java.io.IOException
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.
- 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 not exists then return null - Throws:
java.io.IOException
- If an I/O error occurs
-
-