【发布时间】:2017-04-11 03:34:50
【问题描述】:
我有一些带有此架构的 JSON:
{
"person":{
"name":"test",
"family":"testi"
},
"Employee":{
"id":54,
"department":"web development",
"skils":[{"type":"C#", "grade":"good"},{{"type":"SQL", "grade":"Expert"}}]
}
}
我需要将此 JSON 映射到以下类:
class Employee {
public int id { get; set; }
public string Name { get; set; }
public string Family { get; set; }
public string Department { get; set; }
public Skill[] Skills { get; set;}
}
class skill {
public string Type { get; set; }
public string Grade { get; set; }
}
现在有没有办法将我的 JSON 模式映射到我的 C# 对象?
我正在使用 Newtonsoft.Json 库并尝试像这样使用 JsonProperty 属性:
[JsonProperty("Person.Name")]
在我的Employee 课堂上。但这不起作用。有什么办法可以解决这个问题吗?
【问题讨论】: