1
下面是代碼片段是我的json對象,我希望將數據與我的模型綁定。並且 我想只提取我的樣本模型中的transaction_details值作爲列表。如何從C#中的json對象中提取值
{
"status": 1,
"msg": "3 out of 3 Transactions Fetched Successfully",
"transaction_details": {
"446094091884bf8534e6": {
"mihpayid": "00000000003",
"request_id": "",
"bank_ref_num": "1154234544",
"amt": "1.00",
"transaction_amount": "1.00",
"txnid": "446094091884bf8534e6",
"additional_charges": "0.00",
"productinfo": "Buy Bitcoin",
"firstname": "Pramod",
"bankcode": "ICIB",
"udf1": "",
"udf3": "",
"udf4": "",
"udf5": "",
"field9": "Successful Transaction",
"error_code": "E000",
"card_type": null,
"error_Message": "NO ERROR",
"net_amount_debit": 1,
"disc": "0.00",
"mode": "NB",
"PG_TYPE": "ICICI",
"card_no": "",
"udf2": "",
"addedon": "2017-02-24 12:14:03",
"status": "success",
"unmappedstatus": "captured",
"Merchant_UTR": "dfksdfld",
"Settled_At": "0000-00-00 00:00:00"
},
"446094091884bf8534e7": {
"mihpayid": "00000000002",
"request_id": "",
"bank_ref_num": "1154392922",
"amt": "1.00",
"transaction_amount": "1.00",
"txnid": "446094091884bf8534e7",
"additional_charges": "0.00",
"productinfo": "Buy Bitcoin",
"firstname": "Pramod",
"bankcode": "ICIB",
"udf1": "",
"udf3": "",
"udf4": "",
"udf5": "",
"field9": "Successful Transaction",
"error_code": "E000",
"card_type": null,
"error_Message": "NO ERROR",
"net_amount_debit": 1,
"disc": "0.00",
"mode": "NB",
"PG_TYPE": "ICICI",
"card_no": "",
"udf2": "",
"addedon": "2017-02-24 16:38:00",
"status": "success",
"unmappedstatus": "captured",
"Merchant_UTR": "fasdfafasdfsd",
"Settled_At": "0000-00-00 00:00:00"
},
"446094091884bf8534e8": {
"mihpayid": "00000000001",
"request_id": null,
"bank_ref_num": null,
"amt": "1.00",
"transaction_amount": "1.00",
"txnid": "446094091884bf8534e8",
"additional_charges": "0.00",
"productinfo": "Buy Bitcoin",
"firstname": "Pramod",
"bankcode": "ICIB",
"udf1": "",
"udf3": "",
"udf4": "",
"udf5": "",
"field9": "User interrupted by pressing back button",
"error_code": "E1206",
"card_type": null,
"error_Message": "Transaction interrupted by pressing back button",
"net_amount_debit": "0.00",
"disc": "0.00",
"mode": "NB",
"PG_TYPE": "ICICI",
"card_no": "",
"udf2": "",
"addedon": "2017-02-27 14:03:00",
"status": "failure",
"unmappedstatus": "userCancelled",
"Merchant_UTR": null,
"Settled_At": null
}
}
}
這是我的標本模型
public class sample
{
public string mihpayid { get; set; }
public string request_id { get; set; }
public string bank_ref_num { get; set; }
public string amt { get; set; }
public string transaction_amount { get; set; }
public string txnid { get; set; }
public string additional_charges { get; set; }
public string productinfo { get; set; }
public string firstname { get; set; }
public string bankcode { get; set; }
public string udf1 { get; set; }
public string udf3 { get; set; }
public string udf4 { get; set; }
public string udf5 { get; set; }
public string field9 { get; set; }
public string error_code { get; set; }
public string card_type { get; set; }
public string error_Message { get; set; }
public string net_amount_debit { get; set; }
public string disc { get; set; }
public string mode { get; set; }
public string PG_TYPE { get; set; }
public string card_no { get; set; }
public string udf2 { get; set; }
public string addedon { get; set; }
public string status { get; set; }
public string unmappedstatus { get; set; }
public string Merchant_UTR { get; set; }
public string Settled_At { get; set; }
}
你jusrt需要發送使用POST方法 –
我想提取從JSON對象的實際價值控制器。 –
你想在控制器或jQuery中提取?如果在控制器請chk我的回答 –