I have an array of objects and I need to go through it to get the data and I'm not getting it. I am working with pure javascript.
Solved !!!!!!!
Thanks for the personal help! The array was entering as a string I parse before iterating and everything is solved!
// Example of array received by the function, this array is not declared in this
// js only received as parameter. I am putting so that they can see the format
// of the data received
[{
"id": 171659,
"latitude": "-51.195946",
"longitude": "-30.021810",
"estado": "INSTALADO"
},
{
"id": 171658,
"latitude": "-51.196155",
"longitude": "-30.021615",
"estado": "INSTALADO"
}
]
// My js file contains only the function that receives the data, it follows the
// complete file. The array is not declared here, just received by the function.
// Received successfully but can not iterate
// ====== Get Array ======
function getArray(data) {
var json = JSON.parse(data); //The data enters as string was needed parse()
for (var i = 0; i < json.length; i++) {
console.log(json[i].id); // undefined
}
}
var data = <your array>maybe has something to do with the issue?