{
"Centers": {
"Athens": [
{
"name":"name1",
"lat":"",
"lon":"",
"address":"address1",
"tel":"",
"email":"",
"link":""
},
{
"name":"name2",
"lat":"",
"lon":"",
"address":"address2",
"tel":"",
"email":"",
"link":""
}
]
}
}
I have this JSON file and I want to get the address of an element I specify using its name. Something like this:
alert( stores.Centers.Athens["name"=="name1"].address );
Is there any way I can achieve this, or should I remake my JSON file?
Edit:
.find(x => x.name === 'name1')
doesn't work. It returns 'undefined'. findIndex()
also returns '-1'. I suspect it's because it is a JSON file and not an object list, meaning the property keys are doublequoted.