JSON Serializer

Project Hosting | Nuget: NServiceBus (Version: 4.x)
Standard support for version 4.x of NServiceBus has expired. For more information see our Support Policy.

Using Json via an ILMerged copy of Json.NET.

Usage

Edit
Configure.Serialization.Json();

Json.net versions

Over time the version of ILMerged Json.NET has changed.

NServiceBus VersionJson.net Version
4.04.5.11
4.1 - 5.X5.0.6

Customization

Since Json.net is ILMerged the Json.net customization attributes are not supported. However certain customizations are still supported via standard .NET attributes.

Excluding members

Members can be exclude via the IgnoreDataMemberAttribute.

The attribute can be used as such

public class Person
{
    public string FamilyName { get; set; }
    public string GivenNames { get; set; }

    [IgnoreDataMember]
    public string FullName { get; set; }
}

Then when this is serialized.

Person person = new Person
{
    GivenNames = "John",
    FamilyName = "Smith",
    FullName = "John Smith"
};

The result will be

{"FamilyName":"Smith","GivenNames":"John"}

Bson

Using Bson via the same ILMerged copy of Json.NET as above.

Usage

Edit
Configure.Serialization.Bson();

Samples


Last modified