Jil
Jil copied to clipboard
Serialization behavior for classes with DataContract attribute
Most serializers will handle classes that are tagged with a DataContract attribute in such a way that members that are not tagged with the DataMember attribute are ignored. (see https://msdn.microsoft.com/en-us/library/ms733127(v=vs.110).aspx)
Jil currently does not behave this way. Is this considered a feature? If not, I'd be happy to try and contribute a PR to fix this.
Here's a test to illustrate what I am talking about:
[DataContract]
class _WithDataContract
{
[DataMember]
public string A { get; set; }
public string B { get; set; }
}
[TestMethod]
public void DataContract()
{
{
var json = JSON.Serialize(new _WithDataContract { A = "A", B = "B" });
Assert.AreEqual("{\"A\":\"A\"}", json);
}
}