Sort and merge JSON keys with matching values
问题 My JSON looks like this: json = [ { type: "big" date: "2012-12-08" qty: 6 } { type: "small" date: "2012-12-08" qty: 9 } { type: "big" date: "2012-12-15" qty: 4 } { type: "small" date: "2012-12-07" qty: 7 } { type: "small" date: "2012-11-07" qty: 3 } ] What I'm trying to do is group/merge each type that has a date with the same year & month (the first 7 characters in the date string) and get the sum of those qty 's. The output should look like this: json = [ { type: "big" date: "2012-12" qty: