Jquery 从返回的JSON获取运行总数/百分比

Jquery 从返回的JSON获取运行总数/百分比,jquery,ajax,json,Jquery,Ajax,Json,我正在运行一个查询并获取JSON,返回值表示特定组中的人数。我的数据如下所示: 0: Object count: 10 grp: 1 1: Object count: 20 grp: 2 2: Object count: 30 grp: 3 3: Object count: 40 grp: 4 我想要得到的是运行总数并保存在数组中,因此我将得到如下结果: 0: Object count: 10 grp: 1 1: Object count

我正在运行一个查询并获取JSON,返回值表示特定组中的人数。我的数据如下所示:

0: Object 
  count: 10
  grp: 1
1: Object 
  count: 20
  grp: 2
2: Object 
  count: 30
  grp: 3
3: Object 
  count: 40
  grp: 4
我想要得到的是运行总数并保存在数组中,因此我将得到如下结果:

0: Object 
  count: 10
  grp: 1
1: Object 
  count: 20
  grp: 2
2: Object 
  count: 30
  grp: 3
3: Object 
  count: 40
  grp: 4
[[0,10],[1,30],[2,60],[3100]]

这是我的开始,但不确定我需要在我的
推送中放入什么

d1_1 = [];
$.each(data.rows, function(index, value){
d1_1.push(***what goes here?***);
});

这能奏效吗

var input = [{count:10, grp:1},{count:20,grp:2},{count:30,grp:3},{count:40,grp:4}];
counter = 0;
var d1_1 = [];
jQuery.each(input, function(index, elem) {
counter += elem.count;
d1_1.push([index,counter]);
});

如果要将索引推入数组,可以执行以下操作

var json = [{count: 10, group: 1},{count: 20, group: 2}, {count: 30, group: 3},{count: 40, group: 4}];
var myArray = [];

$.each(json, function(index, value){    
    //Results in [0, 10], [1, 20], etc
    myArray.push([index, value.count]);
    //console.log(myArray);
});
var json = [{count: 10,grp: 1}, {count: 11,grp: 2}],
        result = [],
        temp = [];

    for (var i in json) {
        temp.push(json[i].grp, json[i].count);
        result.push(temp);
        temp = [];
    }