Hey I would like to ask if it is possible to find lets say in 10 JSON files which are looking like this:
1.json:
{
"name": "Miami",
"attributes": [
{
"att_type": "People",
"value": "1000"
},
{
"att_type": "Cars",
"value": 300
}
]
}
2.json:
{
"name": "New York",
"attributes": [
{
"att_type": "People",
"value": "5000"
},
{
"att_type": "Cars",
"value": 900
}
]
}
And so on... just different attribute values. Lets say I want to find only towns with People > 2500 and I'm not even sure if it is possible or do I need to upload the json files to some database perhaps?
Thank you.
const data = [{ "name": "Miami", "attributes": [{ "att_type": "People", "value": "1000" }, { "att_type": "Cars", "value": 300 } ] }, { "name": "New York", "attributes": [{ "att_type": "People", "value": "5000" }, { "att_type": "Cars", "value": 900 } ] } ] const result = data // find cities with attribute `People` with value greater than 2500.filter(d => +d.attributes.find(attr => attr.att_type === 'People').value > 2500) // get name of the city.map(d => d.name) console.log(result)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.