You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
value2
Unhandled exception. System.InvalidOperationException: Nullable object must have a value.
at System.Nullable`1.get_Value()
at test_deser.Program.Main(String[] args) in /tmp/test_deser/Program.cs:line 15
Removing the ? and the Value works as expected:
- System.Console.WriteLine(des.SubObj.Value.Field1);+ System.Console.WriteLine(des.SubObj.Field1);- public Obj1? SubObj { get; set; }+ public Obj1 SubObj { get; set; }
Prints:
value2
value1
On netcore 3.1.3. Using nullable types syntax, but this displays the same behavior with explicit Nullable<Obj1>.
The text was updated successfully, but these errors were encountered:
Related issues: #434, #1256
System.Text.Json
JsonSerializer.DeserializeAsync
fails to deserialize Nullable value types. Running:Prints:
Removing the
?
and theValue
works as expected:Prints:
On netcore 3.1.3. Using nullable types syntax, but this displays the same behavior with explicit
Nullable<Obj1>
.The text was updated successfully, but these errors were encountered: