如何从服务到我的对象反序列化以下结果?我只想要名称,城市和州的价值观。我试着用
{{
"id": "123",
"name": "Kaizen",
"living": {
"city": "Sydney",
"state": "NSW"
},
"Country": {
"name": "Australia",
"region": "APAC"
}
}}
JavaScriptSerializer details= new JavaScriptSerializer();
var detailsOfDoc= service.Deserialize<DoctorDetails>(docDetails.ToString());
My DoctorDetails Class is as follows
public class DoctorDetails
{
public string Name { get; set;}
public string State{ get; set;}
public string City{ get; set;}
}
我在detailsOfDoc变量中看到值为null。
修改
以下响应是我在浏览器中输入ID
时在端点中获得的响应<DoctorDetails xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="Northshore.Details">
<Id>111</Id>
<Name>Kaizen</Name>
<Living>
<City>Sydney</City>
<State>NSW</State>
</Living>
<Country>
<Name>Australia</Name>
<Region>APAC</Region>
</Country>
</DoctorDetails>