I have a Json array with data like this
0: Product {Name: "--Product Name--", CategoryID: "115", Sku: "xxxx", Quantity: 1, Price: 4}
1: Product {Name: "--Product Name--", CategoryID: "115", Sku: "xxxx", Quantity: 1, Price: 4}
2: Product {Name: "--Product Name--", CategoryID: "115", Sku: "xxxx", Quantity: 1, Price: 4}
3: Product {Name: "--Product Name--", CategoryID: "77", Sku: "xxxx", Quantity: 1, Price: 9.99}
4: Product {Name: "--Product Name--", CategoryID: "77", Sku: "xxxx", Quantity: 2, Price: 9.99}
5: Product {Name: "--Product Name--", CategoryID: "77", Sku: "xxxx", Quantity: 1, Price: 9.99}
6: Product {Name: "--Product Name--", CategoryID: "77", Sku: "xxxx", Quantity: 4, Price: 9.99}
I want to create a brief summary of the products stored in the object, by their category Id and their quantity and cost
So the output would be something similar to:
Category Id Quantity Cost
115 3 12
77 8 79.92
Is there an easy way of doing this without making a number of arrays to show which category IDs are in the object and cycling through each product array and then category array in a nested for loop?