parsing nested json object

I have a json file that I'm trying to get values out of. One object is nested inside another in this file. I can isolate the top level values, but not the nested values. It must be a syntax issue. Here's what I'm using.

You're getting undefined because json.total[0] is itself, an array. You need to isolate the specific array insidejson.total[0]. So you would need to do something like json.total[0][0].votes or json.total[0][1].votes.

I think a better structure for your JSON would be something like this:

You don't need to create an array where each entry is a name-value pair. You can directly use an associative-array.

EDIT: To iterate over your associative array, use for..in along with hasOwnProperty(). The hasOwnProperty() check will prevent you from iterating over properties that it has inherited (some third-party libraries pollute the namespace):