C#: Not able to get child value from JSON string - 2

CSharp · Console

/Program.cs

using System;
using System.Linq;
using Newtonsoft.Json;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var responseString = "{\"GetAlertingTransactionsResult\":\"{\\\"Success\\\":true,\\\"Data\\\":[{\\\"RowNum\\\":\\\"1\\\",\\\"TransactionID\\\":\\\"611\\\",\\\"TransactionType\\\":\\\"Authorization\\\",\\\"Channel\\\":\\\"POS\\\",\\\"TxnStatusDescription\\\":\\\"Processed\\\",\\\"ErrorCode\\\":\\\"0000\\\",\\\"MID\\\":\\\"999222222222222\\\",\\\"TID\\\":\\\"99922236\\\",\\\"MerchantName\\\":\\\"NEW POS TEST MERCHANT\\\",\\\"MerchantAddress\\\":\\\"TEST ADDRESS LINE1 TEST ADDRESS LINE2\\\",\\\"TransactionAmount\\\":\\\"999.9900\\\",\\\"TipAmount\\\":\\\"0.0000\\\",\\\"DiscountAmount\\\":\\\"0.0000\\\",\\\"TotalAmount\\\":\\\"999.9900\\\",\\\"ApplicationVersion\\\":\\\"V6.0.0\\\",\\\"ApplicationID\\\":\\\"A0000007362010\\\",\\\"TxnDateTime\\\":\\\"7\\/9\\/2020 2:36:07 PM\\\",\\\"RequestDateTime\\\":\\\"7\\/9\\/2020 2:36:59 PM\\\",\\\"ResponseDateTime\\\":\\\"7\\/9\\/2020 2:36:59 PM\\\",\\\"InvoiceNumber\\\":\\\"4\\\",\\\"OldInvoiceNumber\\\":\\\"0\\\",\\\"BatchNumber\\\":\\\"15\\\",\\\"AuthNumber\\\":\\\"123\\\",\\\"AssociationName\\\":\\\"PayPakCard\\\",\\\"TC\\\":\\\"123\\\",\\\"ExpiryDate\\\":\\\"123\\\",\\\"ARQC\\\":\\\"2C254884E80D7FD2\\\",\\\"CardHolderName\\\":\\\"DEBIT\\/PAYPAK              \\\",\\\"MaskedCardNumber\\\":\\\"2205 60** **** 0476\\\",\\\"Cardtype\\\":\\\"CHIP\\\",\\\"TSI\\\":\\\"6800\\\",\\\"TVR\\\":\\\"123\\\",\\\"AppLabel\\\":\\\"PayPak Debit\\\",\\\"TotalTxnCount\\\":\\\"0\\\",\\\"TerminalSerialNumber\\\":\\\"82683858\\\",\\\"CompositeKey\\\":\\\"123\\\",\\\"PINCaptureCode\\\":\\\"1\\\",\\\"IsReprint\\\":\\\"0\\\",\\\"CustomerMobileNo\\\":null,\\\"IPAddress\\\":\\\"43.245.8.61\\\",\\\"RRN\\\":\\\"123\\\"}],\\\"TotalNumberOfRecords\\\":1}\"}";
		var response = JsonConvert.DeserializeObject<Root>(responseString); 
		Console.WriteLine(response.TransactionsResult.Data.First().TransactionID);
	}
	
    public class Datum    {
        public string RowNum { get; set; } 
        public string TransactionID { get; set; } 
        public string TransactionType { get; set; } 
        public string Channel { get; set; } 
        public string TxnStatusDescription { get; set; } 
        public string ErrorCode { get; set; } 
        public string MID { get; set; } 
        public string TID { get; set; } 
        public string MerchantName { get; set; } 
        public string MerchantAddress { get; set; } 
        public string TransactionAmount { get; set; } 
        public string TipAmount { get; set; } 
        public string DiscountAmount { get; set; } 
        public string TotalAmount { get; set; } 
        public string ApplicationVersion { get; set; } 
        public string ApplicationID { get; set; } 
        public string TxnDateTime { get; set; } 
        public string RequestDateTime { get; set; } 
        public string ResponseDateTime { get; set; } 
        public string InvoiceNumber { get; set; } 
        public string OldInvoiceNumber { get; set; } 
        public string BatchNumber { get; set; } 
        public string AuthNumber { get; set; } 
        public string AssociationName { get; set; } 
        public string TC { get; set; } 
        public string ExpiryDate { get; set; } 
        public string ARQC { get; set; } 
        public string CardHolderName { get; set; } 
        public string MaskedCardNumber { get; set; } 
        public string Cardtype { get; set; } 
        public string TSI { get; set; } 
        public string TVR { get; set; } 
        public string AppLabel { get; set; } 
        public string TotalTxnCount { get; set; } 
        public string TerminalSerialNumber { get; set; } 
        public string CompositeKey { get; set; } 
        public string PINCaptureCode { get; set; } 
        public string IsReprint { get; set; } 
        public object CustomerMobileNo { get; set; } 
        public string IPAddress { get; set; } 
        public string RRN { get; set; } 

    }

    public class Root    {
		public string GetAlertingTransactionsResult { get; set; } 
		private SubRoot _getTransactionsResult;
		public SubRoot TransactionsResult { get =>  _getTransactionsResult ??= JsonConvert.DeserializeObject<SubRoot>(GetAlertingTransactionsResult); } 

    }
	
	public class SubRoot {
		public bool Success { get; set; } 
        public List<Datum> Data { get; set; } 
        public int TotalNumberOfRecords { get; set; } 
	}
}
;