-2

string source

{
"Amount": 16700000,
"CardNumber": "0095",
"MerchantReference": "7654325",
"PaymentReference": "FBN|WEB|WEBP|3-02-2016|170619",
"RetrievalReferenceNumber": "000000088836",
"LeadBankCbnCode": null,
"LeadBankName": null,
"SplitAccounts": [],
"TransactionDate": "2016-02-03T16:41:43.923",
"ResponseCode": "00",
"ResponseDescription": "Approved Successful"
}

how do I get the values of Transaction Date,ResponseDescription and Transaction date with c#. Thank you

lingers
  • 3
  • 1
  • 8

1 Answers1

1

Have a look to this library : https://www.nuget.org/packages/Newtonsoft.Json. Here is the code. First of all, define your object in which you want to put the values. Exemple :

[Serializable]
public class TransactionResponse
{
    public DateTime TransactionDate { get; set; }
    public string ResponseCode { get; set; }
    public string ResponseDescription { get; set; }
}

And then, use your class like that :

using Newtonsoft.Json;

...

string jsonContent = @"{
""Amount"": 16700000,
""CardNumber"": ""0095"",
""MerchantReference"": ""7654325"",
""PaymentReference"": ""FBN|WEB|WEBP|3-02-2016|170619"",
""RetrievalReferenceNumber"": ""000000088836"",
""LeadBankCbnCode"": null,
""LeadBankName"": null,
""SplitAccounts"": [],
""TransactionDate"": ""2016-02-03T16:41:43.923"",
""ResponseCode"": ""00"",
""ResponseDescription"": ""Approved Successful""
}";

var response = JsonConvert.DeserializeObject<TransactionResponse>(jsonContent);
Rom Eh
  • 1,981
  • 1
  • 16
  • 33