-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Text.Json -> Deserialize Null to Integer Property #74008
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionWe hav the following Code:
But it throws a exception when we deserialize a "null" value to a Object with this et Reproduction Stepssee code above Expected behaviorshould use default value for int Actual behaviordoes not work Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
The custom serialization contracts features provides a predicate |
could you simply customize JsonPropertyInfo so that |
we don't use the source code generators at the moment. |
@jogibear9988 that's a contract customization feature we're shipping in 7.0 it works with both code-gen and reflection, it should be in pre-release nuget package JsonSerializerOptions options =...;
options.TypeInfoResolver = new DefaultJsonTypeInfoResolver()
{
Modifiers = { typeInfo => { if (typeInfo.Type == typeof(...)) { /* typeInfo.Properties modification here */ } } }
};
// then: JsonSerializer.Deserialize<...>(json, options); |
Description
We hav the following Code:
But it throws a exception when we deserialize a "null" value to a Object with this et
Reproduction Steps
see code above
Expected behavior
should use default value for int
Actual behavior
does not work
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: