I have a JSON array of the following type:
"team": [
{
"paid": {
"refugee": 2018,
"local": 29000,
"international": 12000
}
},
{
"unpaid": {
"refugee": 2019,
"local": 39000,
"international": 19000
}
}
]
I would like to push the values of matching keys into an array, so that I end up with the following new arrays:
var refugees = [2018, 2019]
var local = [29000, 39000]
var international = [12000, 19000]
and so on..
What would be a simple method of doing this? I have succesfully used jQuery in the past for this but need a Javascript only solution:
$.each(team, function (i, v) {
var teams = v;
console.log(teams);
$.each(v, function (i, v) {
refugees.push(v.refugee);
local.push(v.local);
international.push(v.international);
});
});