public class Website
{
public string Url { get; set; }
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
}