我有一个类,其中我在从 json 文件填充 jsonElement 时遇到一些问题
{
"entities": [
{
"name": "DateTimeENT1",
"description": "This a example",
"uil": {
"uill": "This is my Layout"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
正在被反序列化到此类中:
public class Container {
public ICollection<Entity> Entities {get; set;}
}
public class Entity {
public string Name {get; set;}
public string Descripton {get; set;}
UIL Uil {get; set;}
}
public class UIL{
JsonElement Uill {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
这就是我反序列化它的方式:
var input= JsonConvert.DeserializeObject<Container>(File.ReadAllText(@"init.json"));
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我收到一条错误消息'Error converting value "This is my Layout" to type 'System.Text.Json.JsonElement'. 我该如何克服这个问题? …