I am currently working with JSON data containing information like uf, ivp, and others. My goal is to iterate over all the objects in order to access their properties.
{
"version": "1.5.0",
"autor": "mindicador.cl",
"fecha": "2018-10-31T13:00:00.000Z",
"uf": {
"codigo": "uf",
"nombre": "Unidad de fomento (UF)",
"unidad_medida": "Pesos",
"fecha": "2018-10-31T04:00:00.000Z",
"valor": 27432.1
},
"ivp": {
"codigo": "ivp",
"nombre": "Indice de valor promedio (IVP)",
"unidad_medida": "Pesos",
"fecha": "2018-10-31T04:00:00.000Z",
"valor": 28540.81
},
}
Currently, I have a code snippet that only gives me the names of the objects but I am unable to access their properties:
$.ajax({
type: 'GET',
url: API_REQUEST,
dataType: 'json',
success: function(data) {
$('#mindicador').html(JSON.stringify(data));
let k;
for (k of Object.keys(data)) {
if (k === 'version') continue;
if (k === 'autor') continue;
if (k === 'fecha') continue;
console.log(k.nombre);
}
}
,error: function(jqXHR, textStatus, errorMessage) {
console.log('errorMessage: ' + errorMessage);
}
});