-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JsonIgnoreCondition.WhenWritingDefault and double #41630
Comments
The serializer only looks at the actual default value of the type, meaning runtime/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyInfoOfT.cs Lines 137 to 138 in 756addd
Aside: your use of |
Ok thank you for clearing up that misconception. I will need to use more nullable types then I suspect to get a similar behavior. How do I get both behaviors of ignoring nulls and defaults? If I set ignorenullvalues I am greeted with |
I believe you want |
@steveoh @pinkfloydx33 , the setting you want is wrt. using |
@layomia what is the behavior for |
@pinkfloydx33 - We'll add documentation for all of this behavior - https://docs.microsoft.com/dotnet/standard/serialization/system-text-json-how-to. |
Description
When the prop is set to -1, which is the default value, the property is serialized when
JsonIgnoreCondition.WhenWritingDefault
is set. I would expect that property to not be serialized.Configuration
osx catalina x64
5.0.100-preview.8.20417.9
The text was updated successfully, but these errors were encountered: