I'm very new to JSON, so please don't scald me. I'm trying to find a way to retrieve information from this bit of data, but I'm having zero luck.
var services = [ "Hernia Repair", "Hip Replacement" ... ];
var places = {
"place": [
{
"name": "The Whittington Hospital",
"service": [
"Hernia Repair",
{
"ratings": [
{ "name": "John Doe", "score": 4, "review": "Some text here." },
{ "name": "Jane Doe", "score": 5, "review": "Some more text." }
]
}
...
]
},
]
};
I'm trying to grab the name of the service
and it's ratings
's name
and score
and I've been trying to output it to the console like this:
places.place[0].service.ratings.name
places.place[0].service.ratings.score
But that doesn't seem to be working. If anyone could lend a hand to explain if my nesting is correct or if I'm retrieving them in the correct way.
Any help with this is appreciated.
P.S. Is there also a way to elegantly link the "Hernia Repair" string in the services
array to the "Hernia Repair" string in the place
object?