I have a massive list of airports which I'm intending to use for autocomplete purposes.
I'm currently trying to get rid of some of it's contents which are of no use to me. This is how the contents of the file look like:
{ "Airports": [
{
"iata": "TSS",
"iso": "US",
"status": 1,
"name": "East 34th Street Heliport",
"continent": "NA",
"type": "heliport",
"size": null
},
{
"iata": "FOB",
"lon": "-123.79444",
"iso": "US",
"status": 1,
"name": "Fort Bragg Airport",
"continent": "NA",
"type": "airport",
"lat": "39.474445",
"size": "small"
},
I want to remove everything where type = heliport
and finally save it back to my airports.json
I'm afraid I have no sample code to post since I have no clue what's the way to go here.
Although I have found this function which supposedly does what I'm trying to achieve.
function findAndRemove(array, property, value) {
$.each(array, function(index, result) {
if(result[property] == value) {
//Remove from array
array.splice(index, 1);
}
});
}
findAndRemove(Airports, 'type', 'heliport');
Could this be used to process and then save it back to my airports.json file?