Get children of JSON object python
<p>i am trying to parse some json data in python 2.7, but do not know how to get children elements.</p>

<p>Object structure is like this:</p>

<pre><code>{
    "35": {
        "num": 1,
        "name": "Discovery",
        "stream_type": "live",
        "stream_id": "35"
    },
    "13085": {
        "num": 2,
        "name": "Discovery HD",
        "stream_type": "live",
        "stream_id": "13085"
    },
    "36": {
        "num": 3,
        "name": "Discovery Investigation",
        "stream_type": "live",
        "stream_id": "36"
    },
    "151": {
        "num": 4,
        "name": "Discovery Turbo",
        "stream_type": "live",
        "stream_id": "151"
    }

}
</code></pre>

<p>I load it from url using urllib2 and then use for loop to iterate over it:</p>

<pre><code>&gt; import urllib2,json
&gt; 
&gt; data = urllib2.urlopen("http://someurl.eu/json.php") data =
&gt; data.read().decode("utf-8") channels = json.loads(data)
&gt; 
&gt; for channel in channels:
&gt;     print channel   #prints the id's
</code></pre>

<p>But how i get further ?</p>

<p>If i try:</p>

<pre><code>for channel in channels:
    print channel   #prints the id's
    print channel['name']  #trying to get name
</code></pre>

<p>Then i get:</p>

<blockquote>
  <p>TypeError: string indices must be integers</p>
</blockquote>

<p>I think it wants something like print channel[0] but that just prints me first indice of the id.</p>

<p>I have played around it with other ways also, but i never succeed, anyone can explain a bit please, how this should be done ?</p>