How to deserialize the common format below. I cant change the customers input file. I want to deserialize this input without going through the line by line looking for brackets.
SendAction
2018-10-18T20:04:01.000000
{
"EventDate": "2018-10-18T20:04:01.8278435",
"HeaderVersion": "1.0.0.0",
"Details": [
{
"ApplicationGuid": "3e8eb057-59da-4bfb-9d6c-a533a8f9bd86",
"ApplicationVersion": "1.0.0.0",
"ClickItemID": "",
"Description": "The Large Roads set includes 70 double-sided tiles designed for the gamer who wants large to X-large roads. If you enjoy playing with a large scale and need larger roads, this set is made just for you. The 70 tile set includes interlocking pieces with crossroads, curves and straight options. Additional road fill is provided on the reverse side to give you the variability of size with maximum versatility for your road construction.",
"Discount": 0.0,
"EventType": "ViewDetails",
"ItemID": "793",
"ProductID": "737",
"ProductName": "Land - Large Roads",
"ProductPrice": 19.95,
"Promo": "",
"Quantity": 0,
"TransAmount": 0
}
],
"Session": "wb1i401andnlyd5swzktrsg3",
"SiteGuid": "0bc8986c-2eb1-4ad7-8eba-ba98b58ef666",
"UserEmail": "",
"UserGuid": "00000000-0000-0000-0000-000000000000",
"UserID": "0"
}



David SmithPosted Apr 12, 2022, 12:28 PM
Your last solution takes really long to process. I just did this below and it works fast perfect.
List DetailList = new List();
string[] splitJsonData = jsonData.Split("SendAction").Where(x => !string.IsNullOrEmpty(x)).ToArray();(split);
foreach (var item in splitJsonData )
{
string split = item.Substring(item.IndexOf('{'));
DetailRoot seraphimDetail = JsonConvert.DeserializeObject
DetailList.Add(seraphimDetail);
}
Uttam KumarPosted Apr 12, 2022, 10:48 AM
David SmithPosted Apr 11, 2022, 9:43 AM
David SmithPosted Apr 9, 2022, 8:00 AM
So the solution you provided works now, now I get an error that says "Additional Text encountered after finished reading JSON content when I try to execute the DeserializeObject below".
string json = File.ReadAllText(f);
(text);
string[] splitJsonData = json.Split("SendAction").Where(x => !string.IsNullOrEmpty(x)).ToArray();
newJsonData = new StringBuilder();
foreach (var item in splitJsonData)
{
newJsonData.Append(item.Substring(item.IndexOf('{')));
}
var text = newJsonData.ToString();
DetailRoot output = JsonConvert.DeserializeObject
Uttam KumarPosted Apr 9, 2022, 7:28 AM