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; }

}

 

posted @ 2022-01-10 11:03  奇迹之耀  阅读(85)  评论(0编辑  收藏  举报