Open
Description
Source/destination types
class A {
public A(int arg) {
}
public int field;
}
Source/destination JSON
{"arg": 1, "field": null}
Expected behavior
When new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }
is provided field
property is initialized with default value for int
type
Actual behavior
Unhandled exception. Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int32'. Path 'field'
Steps to reproduce
using Newtonsoft.Json;
public class Program
{
class A {
public A(int arg) {
}
public int field;
}
public static void Main()
{
var result = JsonConvert.DeserializeObject<A>("{\"arg\": 1, \"field\": null}", new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
}
}
Metadata
Assignees
Labels
No labels
Activity