using System.Collections.Generic;
using System.ComponentModel;
using Newtonsoft.Json.Linq;
using System.Globalization;
public static void Main()
""DisplayName"": ""Ticket ID"",
""DisplayName"": ""Last Modified"",
""Value"": ""2022-10-05T18:09:32.1070000Z""
""DisplayName"": ""Last User"",
""Value"": ""SYSTEMACCOUNT""
""DisplayName"": ""Seq_Group"",
Root root = (Root)JsonConvert.DeserializeObject(json, typeof(Root));
Console.WriteLine(JsonConvert.SerializeObject(root, Formatting.Indented));
public Ticket Ticket { get; set; }
public Root(Dictionary<string, JObject> ticket)
foreach (KeyValuePair<string, JObject> kvp in ticket)
string propertyName = kvp.Value.SelectToken("DisplayName").ToString();
PropertyInfo propInfo = typeof(Ticket).GetProperties().FirstOrDefault(x => x.ToName() == propertyName);
JToken value = kvp.Value.SelectToken("Value");
Type propType = propInfo.PropertyType;
if (propType == typeof(DateTime))
propInfo.SetValue(Ticket, DateTime.Parse(value.ToString()));
propInfo.SetValue(Ticket, value.ToObject(propType));
[DisplayName("Ticket ID")]
public int TicketID {get; set;}
[DisplayName("Last Modified")]
public DateTime LastModified {get; set;}
[DisplayName("Last User")]
public string LastUser {get; set;}
public int Seq_Group {get; set;}
public static class ReflectionExtensions
public static string ToName(this PropertyInfo propertyInfo)
object[] displayNameAttributes = propertyInfo
.GetCustomAttributes(typeof(DisplayNameAttribute), false)
if (displayNameAttributes != null && displayNameAttributes.Count() > 0)
return ((DisplayNameAttribute)displayNameAttributes[0]).DisplayName;
return propertyInfo.Name;
return propertyInfo.Name;