using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
"{ 'id': '2201.2302191.Su94GRynNbbqM', 'webpath': [{ 'timestamp': '2022-01-10T19:45:15Z', 'to': 'https://www.test.com/', 'from': 'https://www.test.com/Users/Account/LogOn?ReturnUrl=%2f', 'title': 'test' }] }",
"{ 'id': '2201.2302191.SuFkjnX31bVUK', 'webpath': [[1641942088, 'https://www.test.com/', 'https://www.test.com/Users/Account/LogOn?ReturnUrl=%2f', 'test'],[1641942089, 'https://www.test.com/Redeem?filters=&SearchValue=raffle', null, 'Search - test']] }"
foreach(var json in jsonFormats)
dynamic test = JsonConvert.DeserializeObject(json);
var data = test.webpath[0].GetType() == typeof(JObject)
? JsonConvert.DeserializeObject<Chat>(json)
public static Chat TransformInput(string json)
var format = new { id = "", webpath = new string[0][] };
var preData = JsonConvert.DeserializeAnonymousType(json, format);
var result = new Chat() { id = preData.id };
result.webpath = preData.webpath.Select(TransformEntry).ToList();
public static ChatPath TransformEntry(string[] entry)
return new ChatPath() { timestamp = entry[0], to = entry[1], from = entry[2], title = entry[3] };
public static void OutputResult(Chat data)
Console.WriteLine(string.Format("=======[ Begin Chat {0} ]=======", data.id));
foreach (var entry in data.webpath)
Console.WriteLine(string.Format("Entry {0}:", counter++));
Console.WriteLine("-------");
Console.WriteLine(string.Format("timestamp: {0}", entry.timestamp));
Console.WriteLine(string.Format("title: {0}", entry.title));
Console.WriteLine(string.Format("to: {0}", entry.to));
Console.WriteLine(string.Format("from: {0}", entry.from));
Console.WriteLine("-------");
Console.WriteLine(string.Format("=======[ End Chat {0} ]=======", data.id));
public string id { get; set; }
public List<ChatPath> webpath { get; set; }
public string timestamp { get; set; }
public string title { get; set; }
public string from { get; set; }
public string to { get; set; }