Jil Serializer

Project Hosting
NuGet Package NServiceBus.Jil (2.x) | License
This is a community run project. License and support are independent of Particular Software.
Target NServiceBus Version: 6.x

Using JSON via a NuGet dependency on Jil.

Usage

endpointConfiguration.UseSerialization<JilSerializer>();

Custom Settings

Customizes the instance of Options used for serialization.

var options = new Options(
    prettyPrint: true,
    dateFormat: DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch,
    includeInherited: true);

var serialization = endpointConfiguration.UseSerialization<JilSerializer>();
serialization.Options(options);

Custom Reader

Customize the creation of the JsonReader.

var serialization = endpointConfiguration.UseSerialization<JilSerializer>();
serialization.ReaderCreator(stream =>
{
    return new StreamReader(stream, Encoding.UTF8);
});

Custom Writer

Customize the creation of the JsonWriter.

var serialization = endpointConfiguration.UseSerialization<JilSerializer>();
serialization.WriterCreator(stream =>
{
    return new StreamWriter(stream, Encoding.UTF8);
});

Custom Content Key

When using additional deserializers or transitioning between different versions of the same serializer it can be helpful to take explicit control over the content type a serializer passes to NServiceBus (to be used for the ContentType header).

var serialization = endpointConfiguration.UseSerialization<JilSerializer>();
serialization.ContentTypeKey("custom-key");

Currently not supported

Usages of DataBusProperty<T> since it doesn't have a default constructor. However usage of the databus convention is supported.

Samples


Last modified