JSON.Net Ignore Property during deserialization

前端 未结 6 658
别跟我提以往
别跟我提以往 2020-12-29 19:55

I have a class set up as follows:

public class Foo
{
    public string string1 { get; set; }
    public string string2 { get; set; }
    public string string3         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 20:46

    Adding to drzaus answer: You can use the DefaultContractResolver he suggested .. just in its CreateProperty use property.Ignored = true; instead of property.ShouldSerialize, then its good either when you pass the JsonSerializerSettings to the DeserializeObject function or the SerializeObject function.

提交回复
热议问题