Json.NET:如果指定类型的基类是"PropertyChangedBase",则无法反序列化 JSON。



以下是我的测试代码:

public class Department : Caliburn.Micro.PropertyChangedBase
{
public System.Guid DepartmentId { get; set; }
public string DepartmentName { get; set; }
}
static void Main(string[] args)
{
string jsonString = "{DepartmentName:123}";
Department department = Newtonsoft.Json.JsonConvert.DeserializeObject<Department>(jsonString);
System.Console.WriteLine(department.DepartmentName);
System.Console.ReadKey();
}

结果是;部门名称";作为其初始值为null。

有什么解决方案吗

为每个属性添加[JsonProperty]属性。

最新更新