【发布时间】:2019-03-02 04:42:16
【问题描述】:
我正在尝试使用 newtonsoft deserializeobject 对下面的 json 进行反序列化,但出现以下错误。我怎样才能让它使用它在 json 中声明的类型和 $type 位?错误是真的,因为 VisitType 类是许多类的基本抽象类,FormType 就是其中之一。
无法创建 Messages.VisitType 类型的实例。类型是一个 接口或抽象类,不能实例化。小路 'tasks[0].Id',第 1 行,位置 103。
{
"isFullyComplete":true,
"tasks":[
{
"$type":"Messages.FormType, Messages",
"Id":{"ref":"CP"},
"status":"Complete"
}
],
"identity":
{
"guid":"3fd3b1c2-c700-e911-8080-005056883684"
},
"proRef":"No"
}
【问题讨论】: