Package io.dapr.client

# Class ObjectSerializer

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

Direct Known Subclasses:
  `ActorObjectSerializer`, `DefaultObjectSerializer`

    public class ObjectSerializer
    extends java.lang.Object

Serializes and deserializes an internal object.

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `protected static com.fasterxml.jackson.databind.ObjectMapper` | `OBJECT_MAPPER` | Shared Json serializer/deserializer as per Jackson's documentation.

- ## Constructor Summary

  Constructors
  Modifier | Constructor | Description
  --- | --- | ---
  `protected` | `ObjectSerializer()` | Default constructor to avoid class from being instantiated outside package but still inherited.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `<T> T` | `deserialize​(byte[] content, TypeRef<T> type)` | Deserializes the byte array into the original object.
  `<T> T` | `deserialize​(byte[] content, java.lang.Class<T> clazz)` | Deserializes the byte array into the original object.
  `byte[]` | `serialize​(java.lang.Object state)` | Serializes a given state object into byte array.

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

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

- ## Field Details

  - ### OBJECT_MAPPER

    protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
    Shared Json serializer/deserializer as per Jackson's documentation.

- ## Constructor Details

  - ### ObjectSerializer

    protected ObjectSerializer()
    Default constructor to avoid class from being instantiated outside package but still inherited.

- ## Method Details

  - ### serialize

    public byte[] serialize​(java.lang.Object state) throws java.io.IOException
    Serializes a given state object into byte array.
    Parameters:
      `state` - State object to be serialized.
    Returns:
      Array of bytes[] with the serialized content.
    Throws:
      `java.io.IOException` - In case state cannot be serialized.

  - ### deserialize

    public <T> T deserialize​(byte[] content, TypeRef<T> type) throws java.io.IOException
    Deserializes the byte array into the original object.
    Type Parameters:
      `T` - Generic type of the object being deserialized.
    Parameters:
      `content` - Content to be parsed.
      `type` - Type of the object being deserialized.
    Returns:
      Object of type T.
    Throws:
      `java.io.IOException` - In case content cannot be deserialized.

  - ### deserialize

    public <T> T deserialize​(byte[] content, java.lang.Class<T> clazz) throws java.io.IOException
    Deserializes the byte array into the original object.
    Type Parameters:
      `T` - Generic type of the object being deserialized.
    Parameters:
      `content` - Content to be parsed.
      `clazz` - Type of the object being deserialized.
    Returns:
      Object of type T.
    Throws:
      `java.io.IOException` - In case content cannot be deserialized.