public class Website
{
public string Url { get; set; }
public Website(Website website)
{
//todo...
}
public Website(int value)
{
//todo...
}
}
string json = @"{'Url':'http://www.google.com'}";
try
{
//当反序列化对象无默认构造函数且有两个及以上重载构造函数时,反序列化不知道调用哪个构造函数,会报错
var web = JsonConvert.DeserializeObject<Website>(json);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
// Value cannot be null.
// Parameter name: website
}