Skip to content

System.Text.Json and deserializing that fails when null is received for non-nullable property #62722

Answered by bjornen77
MartyIX asked this question in Q&A
Discussion options

You must be logged in to vote

This is now possible in .NET 7:
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/required-properties

Update: The required properties above does not solve the problem. However, there are some limited support for non-nullable reference type enforcement in .NET 9:
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/nullable-annotations

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
3 replies
@MartyIX
Comment options

@bjornen77
Comment options

@MartyIX
Comment options

Comment options

You must be logged in to vote
4 replies
@MartyIX
Comment options

@Steve-OH
Comment options

@ashikns
Comment options

@bjornen77
Comment options

Answer selected by MartyIX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants