Created
March 7, 2026 23:21
-
-
Save AnthonyGiretti/e8b62c294ccc692e543a53c1320d7299 to your computer and use it in GitHub Desktop.
Before .NET 10, enabling strict validation Deserialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text.Json; | |
| using System.Text.Json.Serialization; | |
| var options = new JsonSerializerOptions | |
| { | |
| AllowDuplicateProperties = false, | |
| UnmappedMemberHandling = JsonUnmappedMemberHandling.Disallow, | |
| PropertyNameCaseInsensitive = false, | |
| RespectNullableAnnotations = true, | |
| RespectRequiredConstructorParameters = true | |
| }; | |
| var user = JsonSerializer.Deserialize<LoginRequest>(jsonPayload, options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment