using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
'Description': 'Describe1',
'Description': 'Describe2',
'Description': 'Describe3',
'Description': 'Describe4',
'Description': 'Describe5',
'Description': 'Describe5',
var parsedJsonObject = JsonConvert.DeserializeObject<List<ObjectName>>(jsonObject);
var normalizedData = parsedJsonObject.SelectMany(pParent => pParent.Category, (pParent, pCategory) =>
new { pParent, pCategory }).Select(ParentAndCategory =>
Cost = ParentAndCategory.pParent.Cost,
Category = ParentAndCategory.pCategory,
var aggregatedData = new List<ObjectName2>();
for(int i = 0; i < (normalizedData.Count - 1);)
aggregatedData.Add(new ObjectName2{ Cost = normalizedData[i].Cost, Category1 = normalizedData[i].Category, Category2 = normalizedData[i + 1].Category });
var result = aggregatedData.GroupBy(p => p.Category1)
data = g.GroupBy(p => p.Category2).Select(g2 =>
new { name = g2.Key, value = g2.Sum(p2 => p2.Cost) })
foreach(var item in result)
Console.WriteLine(JsonConvert.SerializeObject(item));
public string Description { get; set; }
public decimal Cost { get; set; }
public string[] Category { get; set; }
public decimal Cost { get; set; }
public string Category1 { get; set; }
public string Category2 { get; set; }