反序列化Facebook Workplace SCIM Rest API响应 [英] Deserialize Facebook Workplace SCIM Rest API response

查看:98
本文介绍了反序列化Facebook Workplace SCIM Rest API响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#NewtonSoft.Json库反序列化以下对强类型对象的响应. 问题在于如何反序列化最后一部分

I'm trying to deserialize the below response to a strongly typed object using C# NewtonSoft.Json library. The issue is how to deserialize the last part

"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; }
    }

地址"节点的类

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; }
}

推荐答案

好,您应该只创建一个属性,并使用JsonProperty属性:

Well, you should only create a property, and use a JsonProperty attribute :

[JsonProperty(PropertyName = "urn:scim:schemas:extension:enterprise:1.0")]
public YourEnterpriseType Enterprise { get; set; }

虽然不确定Enterprise名称.

关于此文档.

这篇关于反序列化Facebook Workplace SCIM Rest API响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆