title: Parsing JSON array into class instance objects?
body: <p>I'm trying to parse some data in Python I have some JSON:</p>
  <pre class="lang-none prettyprint-override"><code>{
      &quot;data sources&quot;: [
          &quot;http://www.gcmap.com/&quot;
      ],
      &quot;metros&quot;: [
          {
              &quot;code&quot;: &quot;SCL&quot;,
              &quot;continent&quot;: &quot;South America&quot;,
              &quot;coordinates&quot;: {
                  &quot;S&quot;: 33,
                  &quot;W&quot;: 71
              },
              &quot;country&quot;: &quot;CL&quot;,
              &quot;name&quot;: &quot;Santiago&quot;,
              &quot;population&quot;: 6000000,
              &quot;region&quot;: 1,
              &quot;timezone&quot;: -4
          },
          {
              &quot;code&quot;: &quot;LIM&quot;,
              &quot;continent&quot;: &quot;South America&quot;,
              &quot;coordinates&quot;: {
                  &quot;S&quot;: 12,
                  &quot;W&quot;: 77
              },
              &quot;country&quot;: &quot;PE&quot;,
              &quot;name&quot;: &quot;Lima&quot;,
              &quot;population&quot;: 9050000,
              &quot;region&quot;: 1,
              &quot;timezone&quot;: -5
          }
      ]
  }
  </code></pre>
  <p>If I wanted to parse the <code>&quot;metros&quot;</code> array into and array of Python class <code>Metro</code> objects, how would I setup the class?</p>
  <p>I was thinking:</p>
  <pre><code>class Metro(object):
      def __init__(self):
          self.code = 0
          self.name = &quot;&quot;
          self.country = &quot;&quot;
          self.continent = &quot;&quot;
          self.timezone = &quot;&quot;
          self.coordinates = []
          self.population = 0
          self.region = &quot;&quot;
  </code></pre>
  <p>So I want to go through each metro and put the data into a corresponding <code>Metro</code> object and place that object into a Python array of objects...How can I loop through the JSON metros?</p>