im using backbone, jquery, underscore and i'd like to get at some JSON ive got in a local file.
Im currently using
//Will get data but no access to individual objects
$.getJSON('carinfo.json', function(data){
console.log(data);
var data2 = data['unitId'];
console.log(data2);
});
to pull the JSON into the data variable but i dont know where to go from here. How would i for instance get back all of the values from the field name 'carID'?
This is what one of my JSON entries looks like
{
"carID": "xx",
"xxx": {
"unitID": "xxxxxxx",
"positionHistory": [{
"lat": "xxxxx",
"long": "xxxxxxxx",
"time": "xxxxxxxxxx",
"status": "1",
"estimatedSpeed": "0",
"lastSoundFileName": "xxxxx",
"lastSoundRange": "12",
"lastSoundTime": "xxxxxxxx",
"isToday": false,
"minutesAgo": xxxxxx
}]
},
"registration": "xxxxxxx",
"color": "xxxxxxxx",
"phone": "",
"model": "xxxx"
}
Edit: using data.carID returns undefined.
Screenshot of chrome console output