Difference between DataMember and JsonProperty in

2019-04-22 19:11发布

What is the difference between DataMember and JsonProperty when using it in webapi2? Any performance differences? What is preferred to use?

Thanks! Andreas

1条回答
别忘想泡老子
2楼-- · 2019-04-22 20:12

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.

查看更多
登录 后发表回答