What is the difference between DataMember and JsonProperty when using it in webapi2? Any performance differences? What is preferred to use?
Thanks! Andreas
In WebAPI, the default JSON formatter is Json.NET.
Json.NET is the one who reads the DataMember and JsonProperty attributes. JsonProperty is from Json.NET and its purpose is to control how the field or property is serialized. While DataMember, which is from Microsoft, is read by Json.NET for convenience.
JsonProperty provides more configuration options than DataMember.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With