【发布时间】:2019-01-04 07:51:33
【问题描述】:
我的 WCF Web 服务遇到问题。 我有这个错误:
服务器在处理请求时遇到错误。
我认为是由于JSON的反序列化,我将我的代码过去,请给我一些帮助,谢谢。
这是原始 JSON:
{
"properties" : {
"callID" : "4A79825AE0914B6B9B27F477CAF8A32B",
"timestamp" : "2018-06-05T08:50:41.064+0000",
"data" : {
"Name" : "Y",
"Surname" : "X",
"Age" : [ "25" ]
},
"localEvent" : "X",
"eventtype" : "X"
}
}
我有以下课程:
public class CSModel
{
public CSProperties properties { get; set; }
}
public class CSProperties
{
public string callID{ get; set; }
public string timestamp{ get; set; }
public CSData DataModel { get; set; }
public string localEvent{ get; set; }
public string eventtype{ get; set; }
}
public class CSData
{
public string Name{ get; set; }
public string Surname{ get; set; }
public string Age{ get; set; }
}
我在这里解码我的 JSON:
string jsonBody = new StreamReader(contents).ReadToEnd();
CSModel jsonModel = JsonConvert.DeserializeObject<CSModel>(jsonBody);
【问题讨论】:
标签: c# json rest wcf deserialization