json.net - Serializing POCO class derived from baseclass with DataContract? -


i noticed when serializing/deserializing poco class json.net derives base class uses explicit datacontract attributes poco properties on derived class ignored.

for example, in example, "address" not serialized/deserialized:

[datacontract] public class mybaseclass {     [datamember(name = "somename")]     public string name { get; set; } }  public class myderivedclass : mybaseclass {     public string address { get; set; } } 

is intentional?

fwiw, seem datacontractserializer (at least xml one) "right thing" here , serializes/deserializes "address".

thanks!

henrik

in json.net, @ least of v4.5.6, detects datacontract of base class , assumes opt-in serialization. since address not decorated datamember attribute not serialized.

this design according james newton-king no planned change.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -