In object property property notation, each ‘child’ property is accessed with a .
and arrays are normally accessed with brackets [n]
where n
is the index (0 based) of the item.
Let’s take a simpler example:
{
"animal": {
"type": "cat",
"colors": ["red", "orange"]
}
}
We would access the type as animal.type
.
We could get the list (array) of colors as animal.colors
but if we only wanted to get the first color, we would normally access it as animal.colors[0]
and if we wanted the second color we would use animal.colors[1]
(remember that indexes are 0 based with JSON objects)
Hopefully that arbitrary example helps explain and doesn’t just make things more confusing.