var data= [{_id: "5a93cbd49ae761a4015f6346", nombre: "Chicago - Missouri", longitud: "-94.6807924", latitud: "38.287606"},
{ _id: "5a93ca539ae761a4015f6344", nombre: "Boston - Central Falss", longitud: "-71.4111895", latitud: "41.8902971"},
{ _id: "5a93ccbf9ae761a4015f6349", nombre: "Houston - Dallas", longitud: "-97.0117365", latitud: "32.8209296"}]
var d=[];
for(var i in data){
d.push({ data[i].nombre:data[i]["_id"] })
}
I want to create a JSON object with the following structure:
{ "nombre":"_id" }
For instance:
{ "Chicago - Missouri":"5a93cbd49ae761a4015f6346"}
{ "Boston - Central Falss- Missouri": "5a93ca539ae761a4015f6344" }4
Where did I go wrong?
Thank you