-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Support nullable structs in JsonSerializer #30843
Comments
From @andrewjsaid here (https://github.com/dotnet/corefx/issues/41310):
|
Currently we are using this workaround.
|
This comment has been minimized.
This comment has been minimized.
I ran into another problem which may be related to this issue, specifically when dealing with a JsonSerializer.Deserialize<Nullable<DateTime>>("\"\"")
// System.Text.Json.JsonException: 'The JSON value could not be converted to
// System.Nullable`1[System.DateTime]. Path: $ | LineNumber: 0 | BytePositionInLine: 2. The same statement using Newtonsoft.Json deserializes into a If this is already covered by the scope of this issue, then no worries. If you prefer that I open a separate issue for this, let me know. |
The issue you brought up is about trying to coerce an empty string into a null value (in this case the type just happens to be
The workaround would be to special-case/handle that in your own converter. |
Given
Serialization
Deserialization (Debug)
In Release, deserialization returns an instance with null members for the nested
Person
struct.The text was updated successfully, but these errors were encountered: