Newtonsoft.Json仅对类中部分属性进行序列化
[JsonObject(MemberSerialization.OptIn)]
public class TemplateSort
{
public int Id { get; set; }
[JsonProperty]
public string Name { get; set; }
[JsonProperty]
public List<TemplateSort> Cname { get; set; }
}
等同于
[JsonObject(MemberSerialization.OptOut)]
public class TemplateSort
{
[JsonIgnore]
public int Id { get; set; }
public string Name { get; set; }
public List<TemplateSort> Cname { get; set; }
}