JSON.Net Ignore Property during deserialization

前端 未结 6 644
别跟我提以往
别跟我提以往 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:39

    You can use MissingMemberHandling property of the JsonSerializerSettings object.

    Example usage:

    var jsonSerializerSettings = new JsonSerializerSettings();
    jsonSerializerSettings.MissingMemberHandling = MissingMemberHandling.Ignore;
    
    JsonConvert.DeserializeObject(jsonResponse, jsonSerializerSettings);
    

    More info here.

提交回复
热议问题