I am attempting to retrieve information from an httpresponse, parse the JSON, and create a new dictionary with an array of dictionaries similar to:
"data" : {"infracciones": [
{
"folio": "03041487403",
"fecha": "2014-03-16",
"situacion": "Pagada",
"motivo": "POR NO RESPETAR LOS LIMITES DE VELOCIDAD",
},
{
"folio": "0334357403",
"fecha": "2015-04-11",
"situacion": "Pagada",
"motivo": "POR NO RESPETAR LOS LIMITES DE VELOCIDAD",
}],
"tenencia":[ ...]
}
However, I am receiving an error: "Unexpected string in main.js:35" and I am unsure of what is causing it. Thank you for any assistance. Below is the code:
Parse.Cloud.httpRequest({
url: url1 ,
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
}).then(function(httpResponse) {
var json = JSON.parse(httpResponse.data);
var datos = json.infracciones;
var infracciones = [];
var data = {};
var i = 0;
for(i = 0; i < datos.length ; i++){
infracciones[i].["folio"] = datos.folio ; // THIS IS LINE 35
infracciones[i].["fecha"] = datos.fecha ;
infracciones[i].["situacion"] = datos.situacion ;
infracciones[i].["motivo"] = datos.motivo ;
}
data.push({
key : "infracciones",
value : infracciones
});
response.success(data);
console.log(httpResponse.text);
}, function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
});