# DefaultObjectSerializer (dapr-sdk-parent 1.12.2 API)
declaration: package: io.dapr.serializer, class: DefaultObjectSerializer

Package io.dapr.serializer

# Class DefaultObjectSerializer

java.lang.Object
io.dapr.client.ObjectSerializer
io.dapr.serializer.DefaultObjectSerializer

All Implemented Interfaces:
  `DaprObjectSerializer`

public class DefaultObjectSerializer extends ObjectSerializer implements DaprObjectSerializer
Default serializer/deserializer for request/response objects and for state objects too.

## Field Summary

### Fields inherited from class io.dapr.client.ObjectSerializer

`OBJECT_MAPPER`

## Constructor Summary

Constructors
Constructor
Description
`DefaultObjectSerializer()`

## Method Summary

Modifier and Type
Method
Description
`<T> T`
`deserialize(byte[] data, TypeRef<T> type)`
Deserializes the byte array into the original object.
`String`
`getContentType()`
Returns the content type of the request.
`byte[]`
`serialize(Object o)`
Serializes a given state object into byte array.

### Methods inherited from class io.dapr.client.ObjectSerializer

`deserialize, parseNode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefaultObjectSerializer

public DefaultObjectSerializer()

## Method Details

### serialize

public byte[] serialize(Object o) throws IOException
Serializes a given state object into byte array.

Specified by:
  `serialize` in interface `DaprObjectSerializer`
Overrides:
  `serialize` in class `ObjectSerializer`
Parameters:
  `o` - State object to be serialized.
Returns:
  Array of bytes[] with the serialized content.
Throws:
  `IOException` - In case state cannot be serialized.

### deserialize

public <T> T deserialize(byte[] data, TypeRef<T> type) throws IOException
Deserializes the byte array into the original object.

Specified by:
  `deserialize` in interface `DaprObjectSerializer`
Overrides:
  `deserialize` in class `ObjectSerializer`
Type Parameters:
  `T` - Generic type of the object being deserialized.
Parameters:
  `data` - Content to be parsed.
  `type` - Type of the object being deserialized.
Returns:
  Object of type T.
Throws:
  `IOException` - In case content cannot be deserialized.

### getContentType

public String getContentType()
Returns the content type of the request.

Specified by:
  `getContentType` in interface `DaprObjectSerializer`
Returns:
  content type of the request