【发布时间】:2018-01-25 12:13:20
【问题描述】:
我正在尝试使用 C# NewtonSoft.Json 库反序列化以下对强类型对象的响应。 问题是如何反序列化最后一部分
"urn:scim:schemas:extension:enterprise:1.0": {"department": "Headquarters"}
变成一个对象。
{
"schemas": [
"urn:scim:schemas:core:1.0",
"urn:scim:schemas:extension:enterprise:1.0"
],
"userName": "ihabs@olympic.qa",
"name": {
"formatted": "Ihab Mahmoud"
},
"active": true,
"emails": [
{
"primary": true,
"type": "work",
"value": "ihabs@olympic.qa"
}
],
"addresses": [
{
"type": "work",
"formatted": "QOC Headquarter",
"primary": true
}
],
"urn:scim:schemas:extension:enterprise:1.0": {
"department": "Headquarters"
}
}
我的强类型类是
public class WPClass
{
public List<string> Schemas { get; set; }
public string Username { get; set; }
public NameNode Name { get; set; }
public bool Active { get; set; }
public List<EmailNode> Emails { get; set; }
public List<AddressNode> Addresses { get; set; }
}
Address 节点的类
public class AddressNode
{
public string Type { get; set; }
public string formatted { get; set; }
public bool Primary { get; set; }
}
电子邮件节点的类
public class EmailNode
{
public bool Primary { get; set; }
public string Type { get; set; }
public string Value { get; set; }
}
名称节点的类
public class NameNode
{
public string formatted { get; set; }
}
【问题讨论】:
-
你能展示你的强类型类吗?
-
请查看我审核过的答案