Object Array由两个值字段和映射结果组成

时间:2014-08-28 21:47:27

标签: javascript arrays json

我想用2个不同的值字段对javascript对象数组进行分组,然后将结果映射到我的链接。 源:

[{"date":"2012-05-01","casinoName":"Grand Orient Casino","type":"Other","number":"68"},{"date":"2012-06-01","casinoName":"Grand Orient Casino","type":"Free Coins","number":"11"},{"date":"2012-06-01","casinoName":"slotCasino","type":"New Game","number":"40"},{"date":"2012-07-01","casinoName":"Slotomania","type":"Other","number":"17"}]

结果预期:

[{"date":"2012-05-01","Grand Orient Casino Other":"68"},{"date":"2012-06-01","Grand Orient Casino Free Coins":"11", "slotCasino New Game":"40"},{"date":"2012-07-01","Slotomania Other":"17"}]

那我在做什么? 我将casinoName和type值映射为我的键,我的值是number的值。然后我按日期对它们进行分组。 我有问题,因为有效率这样做。 欢迎任何帮助。

0 个答案:

没有答案