Newtonsoft.Json
Newtonsoft.Json copied to clipboard
[FixBug] Error converting value "" to Int64
Solve the following problems
When property type is int32, The following code OK
public class Program
{
public class TestModel
{
public int from { get; set; }
}
public static void Main(string[] args)
{
var json = "{ \"from\": \"\"}";
var ss = JsonConvert.DeserializeObject<TestModel>(json, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Console.WriteLine(ss);
}
}
When property type is int64, The following code throw exception
public class Program
{
public class TestModel
{
public long from { get; set; }
}
public static void Main(string[] args)
{
var json = "{ \"from\": \"\"}";
var ss = JsonConvert.DeserializeObject<TestModel>(json, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Console.WriteLine(ss);
}
}
set NullValueHandling = NullValueHandling.Ignore
they not have the same effect