Issues iterating through JSON list in Python?
<p>I have a file with JSON data in it, like so:</p>

<pre><code>{
    "Results": [
            {"Id": "001",
            "Name": "Bob",
            "Items": {
                "Cars": "1",
                "Books": "3",
                "Phones": "1"}
            },

            {"Id": "002",
            "Name": "Tom",
            "Items": {
                "Cars": "1",
                "Books": "3",
                "Phones": "1"}
            },

            {"Id": "003",
            "Name": "Sally",
            "Items": {
                "Cars": "1",
                "Books": "3",
                "Phones": "1"}
            }]
}
</code></pre>

<p>I can not figure out how to properly loop through the JSON. I would like to loop through the data and get a Name with the Cars for each member in the dataset. How can I accomplish this?</p>

<pre><code>import json

with open('data.json') as data_file:
    data = json.load(data_file)

print data["Results"][0]["Name"] # Gives me a name for the first entry
print data["Results"][0]["Items"]["Cars"] # Gives me the number of cars for the first entry
</code></pre>

<p>I have tried looping through them with:</p>

<pre><code>for i in data["Results"]:
print data["Results"][i]["Name"]    
</code></pre>

<p>But recieve an error:
<strong>TypeError: list indices must be integers, not dict</strong></p>