ServiceStack/ServiceStack.Text — Issue #77: JSON serializer does not honor serialization contract
Author: franklinwise
Created: 2012-02-23 18:26:43+00:00
State: open

If I serialize an object with a null property the framework ignores the Serialization attributes on the property for the Rest contract.

[DataContract]
public class Order
{
[DataMember(Name="name")]
public string Name {get; set;}

[DataMember(Name="specialHandlingCost", EmitDefaultValue=true, IsRequired=true)]
public decimal? SpecialHandlingCost {get; set;}
}

Expected

order: {
name: "Fred",
specialHandlingCost: null,
}

Actual

order: {
name: "Fred"
}