Serialization

Cloudstate functions serve gRPC interfaces, and the input and output messages are protobuf messages that get serialized to the protobuf format. However, in addition to these messages, there are a number of places where Cloudstate serializes other objects, for persistence and for replication. This includes:

Cloudstate supports a number of types and serialization options for these values.

Primitive types

Cloudstate supports serializing the following primitive types:

Protobuf type Java type

string

java.lang.String

bytes

com.google.protobuf.ByteString

int32

java.lang.Integer

int64

java.lang.Long

float

java.lang.Float

double

java.lang.Double

bool

java.lang.Boolean

JSON

Cloudstate uses Jackson to serialize JSON. Any classes that are annotated with @Jsonable will be serialized to and from JSON using Jackson.

Note that if you are using JSON values in CRDT sets or maps, the serialization of these values must be stable. This means you must not use maps or sets in your value, and you should define an explicit ordering for the fields in your objects, using the @JsonPropertyOrder annotation. This constraint is explained in Using Replicated Entities.