Table of Contents

Namespace TypedRest.Serializers

Serialization of entities sent to and received from the server.

Serializers are MediaTypeFormatters. You pass them to the EntryEndpoint constructor and all child endpoints inherit them, so the wire format is decided once for the whole client. See Serializers for the available formats and their default settings, and Custom serializers for writing your own.

class MyClient(Uri uri) : EntryEndpoint(uri, serializer: new XmlSerializer())
{
    // ...
}

An endpoint can hold several serializers, sorted from most to least preferred. All of them are announced in the Accept header and used to deserialize responses according to their content type, while the first one is always used for serializing requests. This lets a client accept multiple formats from a server while still committing to one for its own payloads.

Note

ElementEndpoint.UpdateAsync(Action<JsonPatchDocument<T>>) builds its patch document with Newtonsoft.Json and thus requires a Newtonsoft.Json-based serializer. The other update overloads work with any serializer.

Classes

BsonSerializer

Handles serializing/deserializing from/to BSON using Newtonsoft.Json. Uses camel-case naming and does not serialize null by default.

NewtonsoftJsonSerializer

Handles serializing/deserializing from/to JSON using Newtonsoft.Json. Uses camel-case naming and does not serialize null by default.

SystemTextJsonSerializer

Handles serializing/deserializing from/to JSON using System.Text.Json. Uses camel-case naming and does not serialize null by default.

NuGet: TypedRest.SystemTextJson

XmlSerializer

Handles serializing/deserializing from/to XML using XmlSerializer.