【发布时间】:2021-09-08 22:19:21
【问题描述】:
我看到以前有人问过这类问题。但是,此处发布的所有出色示例都与我的有所不同。我似乎找不到一个看起来像这样的 Json 数组的示例,并且我已经尝试了至少 2 打示例以及将编译的每种类型的反序列化代码,但是无论我尝试什么,我都无法得到这个去工作。任何帮助将不胜感激。
这是我回来的 Json。
{"Value": [
{
"BirthSexId": 1,
"BloodTypeVerificationPending": false,
"CenterPatientId": "80671472",
"DateOfBirth": "1970-02-16T00:00:00",
"EthnicityRace": [
1048576
],
"FirstName": "Candidate",
"HasParentRegistration": false,
"LastName": "323820260",
"ListingCenterCode": "HHHH",
"ListingCenterType": "TX1",
"ListingDateUsedByMatchUtc": "2011-01-21T19:17:26.04Z",
"MedicalUrgencyStatusId": 4099,
"RegistrationAddDateUtc": "2011-01-21T19:17:26.667Z",
"RegistrationId": 681292,
"RegistrationInactiveReasonId": 7,
"RegistrationOrganCode": "KI",
"Removed": false,
"SocialSecurityNumber": "323820260",
"VerifiedBloodTypeCode": "A"
},
{
"BirthSexId": 2,
"BloodTypeVerificationPending": false,
"CenterPatientId": "72240245",
"DateOfBirth": "1974-04-17T00:00:00",
"EthnicityRace": [
33554432
],
"FirstName": "Candidate",
"HasParentRegistration": false,
"LastName": "322823847",
"ListingCenterCode": "HHHH",
"ListingCenterType": "TX1",
"ListingDateUsedByMatchUtc": "2019-07-01T21:13:28.61Z",
"MedicalUrgencyStatusId": 4010,
"RegistrationAddDateUtc": "2019-07-01T21:13:28.693Z",
"RegistrationId": 1203041,
"RegistrationOrganCode": "KI",
"Removed": false,
"SocialSecurityNumber": "322823847",
"VerifiedBloodTypeCode": "A"
}
],
"ValidationResults": [] }
这是我的 C# 类
public class UnosRegistration
{
public Int32 BirthSexId { get; set; }
public Boolean BloodTypeVerificationPending { get; set; }
public String CenterPatientId { get; set; }
public String DateOfBirth { get; set; }
public Int32[] EthnicityRace { get; set; }
public String FirstName { get; set; }
public Boolean HasParentRegistration { get; set; }
public String LastName { get; set; }
public String ListingCenterCode { get; set; }
public String ListingCenterType { get; set; }
public String ListingDateUsedByMatchUtc { get; set; }
public Int32 MedicalUrgencyStatusId { get; set; }
public String RegistrationAddDateUtc { get; set; }
public Int32 RegistrationId { get; set; }
public Int32 RegistrationInactiveReasonId { get; set; }
public String RegistrationOrganCode { get; set; }
public Boolean Removed { get; set; }
public String SocialSecurityNumber { get; set; }
public String VerifiedBloodTypeCode { get; set; }
}
这是我的 C# 代码 sn-p
response = (HttpWebResponse)myWebRequest.GetResponse();
dynamic responseString;
responseString = new StreamReader( response.GetResponseStream() ).ReadToEnd();
List<UnosRegistration> jsonResult = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize( responseString, typeof( List<UnosRegistration> ) );
var RegID = jsonResult.FirstOrDefault().RegistrationId;
感谢您的帮助。
【问题讨论】:
标签: c# arrays json deserialization