Serialize only interface properties to JSON with Json.net

前端 未结 9 1959
孤街浪徒
孤街浪徒 2020-12-08 19:50

With a simple class/interface like this

public interface IThing
{
    string Name { get; set; }
}

public class Thing : IThing
{
    public int Id { get; se         


        
9条回答
  •  隐瞒了意图╮
    2020-12-08 20:26

    in addition to the answer given by @monrow you can use the default [DataContract] and [DataMember] have a look at this

    http://james.newtonking.com/archive/2009/10/23/efficient-json-with-json-net-reducing-serialized-json-size.aspx

提交回复
热议问题