-
Notifications
You must be signed in to change notification settings - Fork 9
Compact Mode
Michael Brown edited this page Dec 2, 2018
·
1 revision
Using compact mode can offer a smaller data size for your type, however there are restrictions. Compact mode must only be used on data types that do not exceed 65k in total size. On classes larger than 65k it will throw an exception and you will need to use the regular non-compact mode (default).
var person = new Person
{
Id = 12345,
Name = "Fred",
Address = new Address
{
Line1 = "Flat 1",
Line2 = "The Meadows"
}
};
var bytes = person.Serialize(SerializerOptions.Compact);
Assert.AreEqual(59, bytes.Length);