I am dealing with a JSON data structure as shown below:
var data = [
{
"type": "Feature",
"id": 1,
"properties":
{
"name": "William",
"categorie": 107,
"laporan":"Fire",
"time":1,
"type": "Firefighter",
"phone_number": "0111111"
}, "geometry":
{
"type": "Point",
"coordinates": [ 106.814893, -6.219156]
}
}
,
{
"type": "Feature",
"id": 7,
"properties":
{
"name": "John",
"categorie": 103,
"laporan":"Thief",
"time":3,
"type": "Police",
"phone_number": "0987654321"
}, "geometry":
{
"type": "Point",
"coordinates": [ 106.794107, -6.286935 ]
}
}
]
My goal is to filter the JSON data above in order to extract properties
and coordinates
based on the time attribute. I attempted to achieve this using the code snippet below, but it did not display the desired outcome:
var data_filter=data.filter(function(item){
return item.properties.time==1;
});
console.log(data_filter)
Can anyone provide insight into how I can effectively filter the JSON data to retrieve properties and coordinate information for specific time values?
Thank you