Json Merge with Array in Javascript

0

I would like to know how to handle a json in javascript like:

var arrDados = {"mes":["12","5","1"], "mes":["2","8","3"]};
var meses = {1:'Jan', 12:'Dez', 6:'Junho', 5:'Abril', 3:'Março', 8:'Agosto', 2:'Fevereiro'}

The idea is that according to the MES index and its Array of numbers where each one indicates a month

12 = > December 3 = > Marches

for (i in arrDados.mes) {
  indice = arrDados.mes[i];
    console.log(indice);
}

So just taking the values from the first json index

details:

Ihaveagridinthesystemlikethis:

    
asked by anonymous 14.06.2018 / 21:55

1 answer

1

I believe that in your case you should receive an array of objects, which would look like this ...

var arrDados = [{"mes": ["12","5","1"]}, {"mes": ["2","8","3"]}];
var meses = {1:'Jan', 12:'Dez', 6:'Junho', 5:'Abril', 3:'Março', 8:'Agosto', 2:'Fevereiro'};

for (i of arrDados) {
    console.log('..........');
    for (m of i.mes) {
    console.log(meses[m]);
  }
}
console.log('..........');
    
14.06.2018 / 22:26