CosmosItemSerializer Class

  • java.lang.Object
    • com.azure.cosmos.CosmosItemSerializer

public abstract class CosmosItemSerializer

The CosmosItemSerializer allows customizing the serialization of Cosmos Items - either to transform payload (for example wrap/unwrap in custom envelopes) or use custom serialization settings or json serializer stacks.

Field Summary

Modifier and Type Field and Description
static final CosmosItemSerializer DEFAULT_SERIALIZER

Gets the default Cosmos item serializer.

Constructor Summary

Modifier Constructor Description
protected CosmosItemSerializer()

Used to instantiate subclasses

Method Summary

Modifier and Type Method and Description
abstract T deserialize(Map<String,Object> jsonNodeMap, Class<T> classType)

Used to deserialize the json tree stored in the Cosmos DB item as a POJO

abstract Map<String,Object> serialize(T item)

Used to serialize a POJO into a json tree

Methods inherited from java.lang.Object

Field Details

DEFAULT_SERIALIZER

public static final CosmosItemSerializer DEFAULT_SERIALIZER

Gets the default Cosmos item serializer. This serializer is used by default when no custom serializer is specified on request options or the CosmosClientBuilder

Constructor Details

CosmosItemSerializer

protected CosmosItemSerializer()

Used to instantiate subclasses

Method Details

deserialize

public abstract T deserialize(Map jsonNodeMap, Class classType)

Used to deserialize the json tree stored in the Cosmos DB item as a POJO

Parameters:

jsonNodeMap - the json tree from the Cosmos DB item
classType - The type of the POJO

Returns:

The deserialized POJO

serialize

public abstract Map serialize(T item)

Used to serialize a POJO into a json tree

Parameters:

item - the POJO to be serialized

Returns:

the json tree that will be used as payload in Cosmos DB items

Applies to