using Newtonsoft.Json.Linq;
using System.Collections.Generic;
public static string NormalizeJson(this string input) {
return JsonConvert.SerializeObject(JsonConvert.DeserializeObject<object>(input), Newtonsoft.Json.Formatting.Indented);
public static void Main()
string oData = "{\"tokenDetails\":[{\"tokenRequestorID\":40010030273,\"tokenReferenceID\":\"DNITHE302023854093242612\",\"panReferenceID\":\"V-3020232651134255142696\",\"entityOfLastAction\":\"TOKEN_REQUESTOR\",\"walletAccountEmailAddressHash\":\"DC064E250CEC859AB3064DCB6BFB888205EDA1A3438C8DE1021D020F744A6E97\",\"clientWalletAccountID\":\"DC064E250CEC859AB3064DCB6BFB8882\",\"panSource\":\"KEY_ENTERED\",\"tokenType\":\"SECURE_ELEMENT\",\"tokenStatus\":\"DEACTIVATED\",\"lastFourOfPAN\":\"6383\"},{\"tokenRequestorID\":40010075001,\"tokenReferenceID\":\"DNITHE302024773412181777\",\"panReferenceID\":\"V-3020232651134255142696\",\"entityOfLastAction\":\"TOKEN_REQUESTOR\",\"walletAccountEmailAddressHash\":\"3030303030303030303030303030303030303030303030303030303030303030\",\"clientWalletAccountID\":\"0EOdJ1RVuGXrDsi0ImCxiaJV\",\"panSource\":\"KEY_ENTERED\",\"tokenType\":\"HCE\",\"tokenStatus\":\"ACTIVE\",\"lastFourOfPAN\":\"6383\"},{\"tokenRequestorID\":40010030273,\"tokenReferenceID\":\"DNITHE302025463049771793\",\"panReferenceID\":\"V-3020232651134255142696\",\"entityOfLastAction\":\"TOKEN_REQUESTOR\",\"walletAccountEmailAddressHash\":\"DC064E250CEC859AB3064DCB6BFB888205EDA1A3438C8DE1021D020F744A6E97\",\"clientWalletAccountID\":\"DC064E250CEC859AB3064DCB6BFB8882\",\"panSource\":\"KEY_ENTERED\",\"tokenType\":\"SECURE_ELEMENT\",\"tokenStatus\":\"INACTIVE\",\"lastFourOfPAN\":\"6383\"},{\"tokenRequestorID\":40010043095,\"tokenReferenceID\":\"DNITHE302026273290304818\",\"panReferenceID\":\"V-3020232651134255142696\",\"entityOfLastAction\":\"TOKEN_REQUESTOR\",\"walletAccountEmailAddressHash\":\"B4DBFF53A261721EAF234B6574DE9F748E87DDF33697196A07A8A701F3BF467B\",\"clientWalletAccountID\":\"eg2t6TyJQ2G8NIraaCypzg\",\"panSource\":\"KEY_ENTERED\",\"tokenType\":\"HCE\",\"tokenStatus\":\"INACTIVE\",\"lastFourOfPAN\":\"6383\"}]}";
var options = new JsonDocumentOptions
AllowTrailingCommas = true
JsonDocument document = JsonDocument.Parse(oData, options);
JObject o = JObject.Parse(oData);
JArray a = (JArray)o["tokenDetails"];
ICollection<visaTokenDetail> oVisaTokens = a.ToObject<ICollection<visaTokenDetail>>();
ICollection<TokenDetail> tokens = a.Select(p => new TokenDetail
tokenRequestorId = (string)p["tokenRequestorID"],
tokenReferenceId = (string)p["tokenReferenceID"],
panReferenceId = (string)p["panReferenceID"],
tokenStatus = (string)p["tokenStatus"],
entityOfLastAction = (string)p["entityOfLastAction"],
tokenType = (string)p["tokenType"],
panSource = (string)p["panSource"],
lastFourOfPAN = (string)p["lastFourOfPAN"]
Console.WriteLine(JsonConvert.SerializeObject(tokens, Formatting.Indented));
public class visaTokenDetail
public string tokenRequestorID { get; set; }
public string tokenReferenceID { get; set; }
public string panReferenceID { get; set; }
public string tokenStatus { get; set; }
public string entityOfLastAction { get; set; }
public string tokenType { get; set; }
public string walletAccountEmailAddressHash { get; set; }
public string panSource { get; set; }
public string clientWalletAccountID { get; set; }
public string lastFourOfPAN { get; set; }
public string tokenRequestorId { get; set; }
public string tokenReferenceId { get; set; }
public string panReferenceId { get; set; }
public string tokenStatus { get; set; }
public string entityOfLastAction { get; set; }
public string tokenType { get; set; }
public string panSource { get; set; }
public string lastFourOfPAN { get; set; }