反序列化Facebook工作场所SCIM Rest API响应
问题描述:
我想反序列化使用C#NewtonSoft.Json库的强类型对象的下面的响应。 问题是如何反序列化最后一部分反序列化Facebook工作场所SCIM Rest API响应
"urn:scim:schemas:extension:enterprise:1.0": {"department": "Headquarters"}
进入一个对象。
{
"schemas": [
"urn:scim:schemas:core:1.0",
"urn:scim:schemas:extension:enterprise:1.0"
],
"userName": "[email protected]",
"name": {
"formatted": "Ihab Mahmoud"
},
"active": true,
"emails": [
{
"primary": true,
"type": "work",
"value": "[email protected]"
}
],
"addresses": [
{
"type": "work",
"formatted": "QOC Headquarter",
"primary": true
}
],
"urn:scim:schemas:extension:enterprise:1.0": {
"department": "Headquarters"
}
}
我Strongle类型类是
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; }
}
为地址节点
public class AddressNode
{
public string Type { get; set; }
public string formatted { get; set; }
public bool Primary { get; set; }
}
类的电子邮件节点的类
虽然[JsonProperty(PropertyName = "urn:scim:schemas:extension:enterprise:1.0")]
public YourEnterpriseType Enterprise { get; set; }
不知道在Enterprise
名称:0
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; }
}
答
那么,你应该只创建一个属性,并使用JsonProperty
属性。
+1
简写为'[JsonProperty(“urn:scim:schemas:extension:enterprise:1.0”)]' – ZwoRmi
+0
非常感谢。这解决了我的问题。欣赏它。 –
你能展示你的强类型类吗? – ZwoRmi
请检查我的评论回答 –