Click or drag to resize
Json.NETMissingMemberHandling setting
 

This sample attempts to deserialize JSON with MissingMemberHandling set to error and a JSON property that doesn't match to a member, causing an exception.

Sample
Types
1public class Account
2{
3    public string FullName { get; set; }
4    public bool Deleted { get; set; }
5}
Usage
 1string json = @"{
 2  'FullName': 'Dan Deleted',
 3  'Deleted': true,
 4  'DeletedDate': '2013-01-20T00:00:00'
 5}";
 6
 7try
 8{
 9    JsonConvert.DeserializeObject<Account>(json, new JsonSerializerSettings
10    {
11        MissingMemberHandling = MissingMemberHandling.Error
12    });
13}
14catch (JsonSerializationException ex)
15{
16    Console.WriteLine(ex.Message);
17    // Could not find member 'DeletedDate' on object of type 'Account'. Path 'DeletedDate', line 4, position 23.
18}