Difficulty accessing multi-dimensional array from JSON data
<p>Here is the JSON data in question:</p>

<pre><code>{
  "result_index": 0,
  "results": [
    {
      "alternatives": [
        {
          "confidence": 0.994,
          "transcript": "thunderstorms could produce large hail isolated tornadoes and heavy rain "
        }
      ],
      "final": true
    }
  ]
</code></pre>

<p>}</p>

<p>Here is how I am attemption to access it.</p>

<pre><code>parsed = json.loads(data)
print(parsed['results']['alternatives']['transcript'])
</code></pre>

<p>This results in the following error:</p>

<pre><code>TypeError: list indices must be integers or slices, not str
</code></pre>

<p>It seems as though results is just an array with a single entry that is a string, and I am a bit confused how to access the individual elements within it.</p>

<p>Your <code>results</code> and <code>alternatives</code> are not objects; but arrays of objects.</p>

<pre><code>print(parsed['results'][0]['alternatives'][0]['transcript'])
</code></pre>

python json