Open ker1o opened 2 months ago
The NullValueHandling.Ignore only working for Serialize not Deserialize.
I would suggest to use a Nullable int:
public int? field;
and judge the value before using:
if(field.HasValue)
@ranistar
The NullValueHandling.Ignore only working for Serialize not Deserialize.
That is entirely incorrect. The issue report is valid - it's an actual bug/quirk with Newtonsoft.Json.
Source/destination types
Source/destination JSON
Expected behavior
When
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }
is providedfield
property is initialized with default value forint
typeActual behavior
Unhandled exception. Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int32'. Path 'field'
Steps to reproduce