CSS
- 7 ответов
- 0 вопросов
3
Вклад в тег
var jsonObj = $.parseJSON('[{"id":1, "amount":123, "currency" : "CHF"},{"id":2, "amount":321, "currency" : "USD"},{"id":3, "amount":4324, "currency" : "UAH"},{"id":4, "amount":45645, "currency" : "USD"},{"id":5, "amount":8972, "currency" : "CHF"}]');
var data = {};
$.each(jsonObj, function(index, value){
if(!data.hasOwnProperty(value.currency)){
data[value.currency] = value.amount;
}else{
data[value.currency] = data[value.currency] + parseInt(value.amount);
}
});