Remove empty string properties from json serialized object

前端 未结 4 1121
暖寄归人
暖寄归人 2020-12-15 23:06

I have a class. It has several properties lets say 10. Out of these 10, 3 are filled with data remaining 7 are blank.i.e. empty strings \"\" Used this link as reference. I w

4条回答
  •  时光取名叫无心
    2020-12-15 23:34

    You can also use two annotations as follows:

    [DefaultValue("")]
    [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
    public string Category { get; set; }
    

提交回复
热议问题