在C#代码中序列化的序列化错误
我正在尝试从API中加载数据,该数据由C#中的JSON数据组成。但是,当我尝试使用 serialialser.deserialize<字典< string,string> []> 数据时,我会遇到错误。
以下是以下一个记录的示例API数据
"_index": "reportingp",
"_type": "_doc",
"_id": "9484478",
"_version": 1,
"_seq_no": 493807,
"_primary_term": 1,
"found": true,
"_source": {
"claimNumber": "1234567890",
"claimICN": "999999",
"claimStatus": "A",
"claimType": "I",
"claimFirstDateService": "2022-01-08",
"claimLastDateService": "2022-01-08",
"isBehaviourHealth": "false",
"claimPatientAccountNumber": "885214L",
"claimBillingAmount": "18281.52",
"claimPaidAmount": "872.47",
"claimCAE": "UHONE",
"subscriberId": "100937717",
"memberId": "100937717",
"subscriberFirstName": "KARIMA",
"subscriberLastName": "AQATRANI",
"subscriberDateOfBirth": "1962-05-02",
"subscriberAddress": "2807 MERRILL ST ",
"patientFirstName": "KARIMA",
"patientLastName": "AQATRANI",
"patientMiddleName": "S",
"patientDateOfBirth": "1962-05-02",
"govProgramCode": "1",
"coverageStartDate": "2017-03-01",
"coverageEndDate": "9999-12-31",
"groupNumber": "NEA6",
"relationshipCode": "EE",
"sourceId": "lkio789456",
"billingMpin": "002629478",
"billingProviderName": "Mercy Gilbert Medical Center",
"renderingMpin": "002629478",
"ticketNumber": "9484478",
"tpsmCode": "S",
"ticketTpsmIndicator": "418",
"ticketTpsmDescription": "STRATEGIC_WEST_DIGNITY HEALTH",
"ticketTpsmEffectiveDate": "2017-03-23",
"ticketSubmissionDate": "2022-02-01",
"ticketSubmitterName": "Akash Sangal",
"ticketType": "Recon",
"ticketQueue": "UHONE",
"providerTin": "63845",
"policyNumber": "D",
"ticketStatus": "Under Review",
"requestReasonAdjuster": "Paper or Electronic Check",
"ticketSubmitterEmail": "[email protected]",
"ticketSubmitterPhone": "1111111111",
"amountOwned": "11.00",
"amountOwnedFlag": "N",
"ticketAssigneeName": "Agarwal, Sagar",
"ticketAssigneeId": "sagarw79",
"ticketConclusion": "On Hold",
"ticketLastUpdated": "2022-02-01",
"ticketLastUpdatedBy": "sagarw79",
"claimSubmissionTransactionId": "N/A",
"sourceApplication": "SDE",
"serviceProviderLastName": "Mercy Gilbert Medical Center",
"productId": "NESHADCP",
"depedentSequenceNumber": "01",
"stateOfIssue": "NE",
"subscriberAddressLine1": "2807 MERRILL ST",
"subscriberCity": "LINCOLN",
"subscriberState": "NE",
"subscriberZip5": "68503",
"billingType": "131",
"claimIndicator": "O",
"claimRecievedDate": "2022-01-19",
"ticketLastUpdatedName": "Agarwal, Sagar",
"ticketTpsmCancelDate": "9999-12-31",
"planBenefitTypeCode": "MD",
"claimNetworkStatus": "O",
"offshoreRestricted": "N",
"isEmployeeRestricted": "N",
"providerComments": "test",
"platform": "UHONE",
"payerId": "87726",
"payerName": "HealthCare",
"kafkaWorkflow": "COMPLETED",
"providerRequestReason": "Paper or Electronic Check",
"resubmissionCount": "0",
"isClosed": "no",
"assignedTopic": "kaas.g",
"cu_ticketSubmittedDate_date": "2022-02-01 09:15:23",
"cu_ticketLastUpdated_date": "2022-02-01 09:29:34.978",
"cu_ticketNumber": "PIQ-9484478",
"cu_totalAttachments_int": 0,
"cu_resubmission_count_int": 0,
"cu_bizAge_int": 1,
"actualClaimNumber": "1234567890",
"coverageType": "M",
"facetsprovIdBilling": "99999999",
"facetsprovIdRendering": "99999999",
"ticketResubmissions": [
{
"openDate": "2022-02-01"
}
],
"ticketComments": [
{
"comment": "test",
"category": "External",
"createdBy": "Akash Sangal",
"createDate": "2022-02-01",
"reconRequestReason": "Paper or Electronic Check"
},
{
"comment": "Received, working on request.",
"category": "Internal",
"createdBy": "Agarwal, Sagar",
"ticketStatus": "Under Review",
"createDate": "2022-02-01",
"conclusion": "On Hold",
"reconRequestReason": "Paper or Electronic Check",
"createdById": "98765we"
}
]
}
}
是我试图从API中获取数据的C#代码,
我正在Visual Studio 2017数据工具脚本组件中实现此功能。
string connetionString = null;
string sql = null;
string serviceUrl = "http://URLLINK/reportingp/_doc/9484478";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(serviceUrl);
var serializer = new JavaScriptSerializer();
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(newMediaTypeWithQualityHeaderValue("application/json"));
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("Username:Password");
string val = System.Convert.ToBase64String(plainTextBytes);
client.DefaultRequestHeaders.Add("Authorization", "Basic " + val);
connetionString = "Data Source=Bharat_PC;Initial Catalog=Practice_OPS; Trusted_Connection=True;";
string APIUrl = string.Format(serviceUrl);
var response = client.GetAsync(APIUrl).Result;
if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
MessageBox.Show(result);
var dt = serializer.Deserialize<Dictionary<string,string>[]>(result);
using (SqlConnection cnn = new SqlConnection(connetionString))```
In the MessageBox.Show(result); I am getting the output but in the next step while doing *serializer.Deserialize<Dictionary<string,string>[]>(result)* I am getting the error. Tried so many approaches but I am unable to fix it. Please help me with the solution.
I am trying to load the data from the API which consists of JSON data in C#. But I am getting an error when I am trying to serializer.Deserialize<Dictionary<string,string>[]> the data.
Below is the sample API data for one record
"_index": "reportingp",
"_type": "_doc",
"_id": "9484478",
"_version": 1,
"_seq_no": 493807,
"_primary_term": 1,
"found": true,
"_source": {
"claimNumber": "1234567890",
"claimICN": "999999",
"claimStatus": "A",
"claimType": "I",
"claimFirstDateService": "2022-01-08",
"claimLastDateService": "2022-01-08",
"isBehaviourHealth": "false",
"claimPatientAccountNumber": "885214L",
"claimBillingAmount": "18281.52",
"claimPaidAmount": "872.47",
"claimCAE": "UHONE",
"subscriberId": "100937717",
"memberId": "100937717",
"subscriberFirstName": "KARIMA",
"subscriberLastName": "AQATRANI",
"subscriberDateOfBirth": "1962-05-02",
"subscriberAddress": "2807 MERRILL ST ",
"patientFirstName": "KARIMA",
"patientLastName": "AQATRANI",
"patientMiddleName": "S",
"patientDateOfBirth": "1962-05-02",
"govProgramCode": "1",
"coverageStartDate": "2017-03-01",
"coverageEndDate": "9999-12-31",
"groupNumber": "NEA6",
"relationshipCode": "EE",
"sourceId": "lkio789456",
"billingMpin": "002629478",
"billingProviderName": "Mercy Gilbert Medical Center",
"renderingMpin": "002629478",
"ticketNumber": "9484478",
"tpsmCode": "S",
"ticketTpsmIndicator": "418",
"ticketTpsmDescription": "STRATEGIC_WEST_DIGNITY HEALTH",
"ticketTpsmEffectiveDate": "2017-03-23",
"ticketSubmissionDate": "2022-02-01",
"ticketSubmitterName": "Akash Sangal",
"ticketType": "Recon",
"ticketQueue": "UHONE",
"providerTin": "63845",
"policyNumber": "D",
"ticketStatus": "Under Review",
"requestReasonAdjuster": "Paper or Electronic Check",
"ticketSubmitterEmail": "[email protected]",
"ticketSubmitterPhone": "1111111111",
"amountOwned": "11.00",
"amountOwnedFlag": "N",
"ticketAssigneeName": "Agarwal, Sagar",
"ticketAssigneeId": "sagarw79",
"ticketConclusion": "On Hold",
"ticketLastUpdated": "2022-02-01",
"ticketLastUpdatedBy": "sagarw79",
"claimSubmissionTransactionId": "N/A",
"sourceApplication": "SDE",
"serviceProviderLastName": "Mercy Gilbert Medical Center",
"productId": "NESHADCP",
"depedentSequenceNumber": "01",
"stateOfIssue": "NE",
"subscriberAddressLine1": "2807 MERRILL ST",
"subscriberCity": "LINCOLN",
"subscriberState": "NE",
"subscriberZip5": "68503",
"billingType": "131",
"claimIndicator": "O",
"claimRecievedDate": "2022-01-19",
"ticketLastUpdatedName": "Agarwal, Sagar",
"ticketTpsmCancelDate": "9999-12-31",
"planBenefitTypeCode": "MD",
"claimNetworkStatus": "O",
"offshoreRestricted": "N",
"isEmployeeRestricted": "N",
"providerComments": "test",
"platform": "UHONE",
"payerId": "87726",
"payerName": "HealthCare",
"kafkaWorkflow": "COMPLETED",
"providerRequestReason": "Paper or Electronic Check",
"resubmissionCount": "0",
"isClosed": "no",
"assignedTopic": "kaas.g",
"cu_ticketSubmittedDate_date": "2022-02-01 09:15:23",
"cu_ticketLastUpdated_date": "2022-02-01 09:29:34.978",
"cu_ticketNumber": "PIQ-9484478",
"cu_totalAttachments_int": 0,
"cu_resubmission_count_int": 0,
"cu_bizAge_int": 1,
"actualClaimNumber": "1234567890",
"coverageType": "M",
"facetsprovIdBilling": "99999999",
"facetsprovIdRendering": "99999999",
"ticketResubmissions": [
{
"openDate": "2022-02-01"
}
],
"ticketComments": [
{
"comment": "test",
"category": "External",
"createdBy": "Akash Sangal",
"createDate": "2022-02-01",
"reconRequestReason": "Paper or Electronic Check"
},
{
"comment": "Received, working on request.",
"category": "Internal",
"createdBy": "Agarwal, Sagar",
"ticketStatus": "Under Review",
"createDate": "2022-02-01",
"conclusion": "On Hold",
"reconRequestReason": "Paper or Electronic Check",
"createdById": "98765we"
}
]
}
}
Below is the C# Code which I am trying to pull the data from API,
I am implementing this in visual studio 2017 data tools script component.
string connetionString = null;
string sql = null;
string serviceUrl = "http://URLLINK/reportingp/_doc/9484478";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(serviceUrl);
var serializer = new JavaScriptSerializer();
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(newMediaTypeWithQualityHeaderValue("application/json"));
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("Username:Password");
string val = System.Convert.ToBase64String(plainTextBytes);
client.DefaultRequestHeaders.Add("Authorization", "Basic " + val);
connetionString = "Data Source=Bharat_PC;Initial Catalog=Practice_OPS; Trusted_Connection=True;";
string APIUrl = string.Format(serviceUrl);
var response = client.GetAsync(APIUrl).Result;
if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
MessageBox.Show(result);
var dt = serializer.Deserialize<Dictionary<string,string>[]>(result);
using (SqlConnection cnn = new SqlConnection(connetionString))```
In the MessageBox.Show(result); I am getting the output but in the next step while doing *serializer.Deserialize<Dictionary<string,string>[]>(result)* I am getting the error. Tried so many approaches but I am unable to fix it. Please help me with the solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下
您可以使用下图和内部httprequest成功响应块
You can try it with below
And inside HTTPRequest Success response block