Skip to content

Serializers

Serializers control how entities are serialized when sending requests and deserialized when receiving responses.

TypedRest provides serializers for various transport formats:

Format C#/.NET Java/Kotlin TypeScript
JSON Built-in Built-in Built-in
XML Built-in Built-in
BSON Built-in

You can also create and use custom serializers.

Inheritance

When creating endpoints, the serializer is automatically inherited from the parent (referrer) endpoint:

var client = new EntryEndpoint(
    new Uri("http://example.com/"),
    serializer: new SystemTextJsonSerializer());

var contacts = new CollectionEndpoint<Contact>(client, relativeUri: "./contacts");
// contacts uses the same SystemTextJsonSerializer
const client = new EntryEndpoint(
    new URL("http://example.com/"),
    new CustomSerializer());

const contacts = new CollectionEndpoint<Contact>(client, "./contacts");
// contacts.serializer is automatically set to the same CustomSerializer

This inheritance ensures consistent serialization behavior across your entire endpoint hierarchy.