using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Web.Script.Serialization; string example = System.IO.File.ReadAllText("D://Result.txt"); var JsonResult = JObject.Parse(example); if (JsonResult["transaction_details"] != null) { var success = JsonResult["transaction_details"].First.ToString(); if (success != null) { int len = success.ToString().IndexOf(":") + 1; var FinalJson = JObject.Parse(success.Substring(len)); if (FinalJson != null) { IntentFlowProperty flight = Newtonsoft.Json.JsonConvert.DeserializeObjectJSON Strting:- {"status":1,"msg":"1 out of 1 Transactions Fetched Successfully","transaction_details":{"SAOAO1000010147-20210608185806":{"mihpayid":"403993715523232833","request_id":null,"bank_ref_num":null,"amt":"1.00","transaction_amount":"1.00","txnid":"SAOAO1000010147-20210608185806","additional_charges":"0.00","productinfo":"ABCDEF","firstname":"MURLI","bankcode":"INTENT","udf1":null,"udf3":null,"udf4":null,"udf5":null,"field2":null,"field9":null,"error_code":null,"addedon":"2021-06-08 18:58:07","payment_source":"payuPureS2S","card_type":null,"error_Message":"","net_amount_debit":"0.00","disc":"0.00","mode":"UPI","PG_TYPE":"UPI-PG","card_no":"","udf2":null,"field5":null,"field7":null,"status":"pending","unmappedstatus":"in progress","Merchant_UTR":null,"Settled_At":null,"App_Name":null}}}(FinalJson.ToString()); } } } public class IntentFlowProperty { public string mihpayid { get; set; } public object request_id { get; set; } public object 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 object udf1 { get; set; } public object udf3 { get; set; } public object udf4 { get; set; } public object udf5 { get; set; } public object field2 { get; set; } public object field9 { get; set; } public object error_code { get; set; } public string addedon { get; set; } public string payment_source { get; set; } public object 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 object udf2 { get; set; } public object field5 { get; set; } public object field7 { get; set; } public string status { get; set; } public string unmappedstatus { get; set; } public object Merchant_UTR { get; set; } public object Settled_At { get; set; } public object App_Name { get; set; } }
Tuesday, June 8, 2021
DeserializeObject JSON to Object in asp.net C#, OR We can say Convert JSON to C# Object
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment