"prices": {
"eur": {
"per_user": 23,
"periodic": 212
},
"sek": {
"per_user": "12",
"periodic": "222"
},
"usd": {
"per_user": "12",
"periodic": "21"
}
}
forEach(prices, (value, key) => {
key.value['per_user'] = parseInt(value.per_user);
key.value['periodic'] = parseInt(value.periodic);
});
var obj = {"prices": {
"eur": {
"per_user": 23,
"periodic": 212
},
"sek": {
"per_user": "12",
"periodic": "222"
},
"usd": {
"per_user": "12",
"periodic": "21"
}
}};
// СУПЕР КОД
var result = JSON.parse(JSON.stringify(obj), function (a, b) {
if (typeof b === 'string') {
b = +b;
}
return b;
});
Object.keys(prices).forEach(currency =>
Object.keys(prices[currency]).forEach(key =>
prices[currency][key] = parseInt(prices[currency][key])
)
)
Object.keys(prices).forEach(currency => {
prices[currency].per_user = parseInt(prices[currency].per_user)
prices[currency].periodic = parseInt(prices[currency].periodic)
})