JSON Serializer

Project Hosting
NuGet Package NServiceBus (3.x)
Standard support for version 3.x of NServiceBus has expired. For more information see our Support Policy.
In Versions 7 and above of NServiceBus, the JsonSerializer has been removed. Use the external Json.NET Serializer instead. See also Compatibility between the core and external Json.NET serializer.

Using JSON via an ILMerged copy of Json.NET.

Usage

configure.JsonSerializer();

Json.net versions

Version 4.0.8 of Json.Net is ILMerged.

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

configure.BsonSerializer();

Samples


Last modified