Skip to content

Instantly share code, notes, and snippets.

@nishanc
Created August 6, 2023 07:12
Show Gist options
  • Save nishanc/5b48f9c945bc23f3c946b59aae4327cb to your computer and use it in GitHub Desktop.
Save nishanc/5b48f9c945bc23f3c946b59aae4327cb to your computer and use it in GitHub Desktop.
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
public class MyPoco
{
public int Id { get; set; }
}
JsonSerializer.Deserialize<MyPoco>("""{"Id" : 42, "AnotherId" : -1 }""");
// JsonException : The JSON property 'AnotherId' could not be mapped to any .NET member contained in type 'MyPoco'.
// Set JsonSerializerOptions.UnmappedMemberHandling to either Skip or Disallow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment