c# - 使用 CRM 365 API 反序列化 json c#
问题描述
所以,我做了这样的课程:
public class Values
{
public string odata_context { get; set; }
public List<ContactsDeserialize> keyValues { get; set; }
}
public class ContactsDeserialize : IDisposable
{
public string odata_etag { get; set; }
public Guid contactid { get; set; }
public string crimson_title { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public DateTime? createdon { get; set; }
public DateTime? birthdate { get; set; }
public string emailaddress1 { get; set; }
public string mobilephone { get; set; }
public string address1_line1 { get; set; }
public string address1_line2 { get; set; }
public string address1_line3 { get; set; }
public string address1_city { get; set; }
public string address1_postalcode { get; set; }
public string address1_telephone1 { get; set; }
}
但是当我尝试通过使用反序列化它时
Values ContactData = JsonConvert.DeserializeObject<Values>(jsonstring);
它返回空值。查不出原因
谢谢
解决方案
您的类字段与原始 json 字段略有不同,因此如果您想使用它,您需要将属性放入您的字段以提供正确的 json 字段,即
[JsonProperty("@odata.etag")]
public string odata_etag { get; set; }
有关更多详细信息,请参阅文档文章
推荐阅读
- blockchain - 我的智能合约没有响应并且错误提示 web3 未定义
- youtube - YouTube 嵌入在特定时间开始不起作用
- apache-spark - 从 spark 编写 AVRO 时 Iceberg 不工作
- android - 创建一个 MPAndroidChart 来显示数据,但是没有显示任何内容
- java - org.apache.catalina.connector.ClientAbortException:java.io.EOFException:在套接字上读取了意外的 EOF
- node.js - mongoose.connect 函数给出错误信息
- java - 如何将捕获的图像保存到图库?
- docker-swarm - Docker Windows 主节点“docker swarm init”导致同一虚拟网络中的工作节点不再看到主节点
- loops - 我正在与一个班级一起改变声音的音高,但我无法让声音循环播放
- mysql - 在mysql查询中,当转换十进制值时,它显示不同的值