Rameez Javed

Rameez Javed

  • NA
  • 395
  • 57.9k

Best way to Group by and Sum the Json object values

Nov 17 2018 9:57 AM
Hi, I'm appending json to html table but the thing is i want to get the item grouped by CategoryID and one thing to mention here i want to sum the values and add an row after here.
  1. var dataString='[   
  2.  { "catID" : "2454""Name" : "Samsung""Price" : 28$ },  
  3.  { "catID" : "2454""Name" : "Nokia""Price" : 17$},  
  4.  { "catID" : "2454""Name" : "iPhone""Price" : 95$},  
  5.  { "catID" : "3888""Name" : "Canon""Price" : 550$},  
  6.  { "catID" : "3338""Name" : "Haier""Price" : 390$},  
  7.  { "catID" : "3888""Name" : "Nikon""Price" : 290$},  
  8.  { "catID" : "4999""Name" : "Hp""Price" : 311$},  
  9.  { "catID" : "4999""Name" : "Dell""Price" : 320$},  
  10.  { "catID" : "3338""Name" : "Orient""Price" : 350$}   
  11. ]';  
i want to add a row after each category for the sum(Price) of that category.
Any help will be appreciated
Thanks 

Answers (1)