I have an array retrieved from a JSON file and I am using dataArray.forEach(function(e, idx, array)
to loop every element and create a table.
I can simply call for each element with console.log(e.id)
but how can I list properties with incremental numbers on them without specifying it or its exact the position in loop?
I need to end up with something like this console.log(e.dp_1.value);
but instead of this number I wish to use idx
. Is this possible?
I have heard there is getChildByName
but not sure how to use it and if it fits.
{
"devices": [{
"id": 0,
"sn": "#12BB56CC9",
"dp_1": {
"value": "65345",
"multiplier": 0.001,
"digits": 2
},
"dp_2": {
"value": "55345",
"multiplier": 0.001,
"digits": 2
}
},
// much more like those
]
}