title: How Can I Parse Google Maps API Data In Python?
body: <p>I am trying to parse the json data that I am receiving</p>
  
  <pre><code>    {'results': [{'address_components': [{'long_name': 'New York',
                                        'short_name': 'New York',
                                        'types': ['locality', 'political']},
                                       {'long_name': 'New York',
                                        'short_name': 'NY',
                                        'types': ['administrative_area_level_1',
                                                  'political']},
                                       {'long_name': 'United States',
                                        'short_name': 'US',
                                        'types': ['country', 'political']}],
                'formatted_address': 'New York, NY, USA',
                'geometry': {'bounds': {'northeast': {'lat': 40.9152414,
                                                      'lng': -73.70027209999999},
                                        'southwest': {'lat': 40.495908,
                                                      'lng': -74.2590879}},
                             'location': {'lat': 40.7143528,
                                          'lng': -74.00597309999999},
                             'location_type': 'APPROXIMATE',
                             'viewport': {'northeast': {'lat': 40.9152414,
                                                        'lng': -73.70027209999999},
                                          'southwest': {'lat': 40.4959143,
                                                        'lng': -74.2557349}}},
                'types': ['locality', 'political']},
               {'address_components': [{'long_name': 'Manhattan',
                                        'short_name': 'Manhattan',
                                        'types': ['sublocality',
                                                  'political']},
                                       {'long_name': 'New York',
                                        'short_name': 'New York',
                                        'types': ['locality', 'political']},
                                       {'long_name': 'New York',
                                        'short_name': 'New York',
                                        'types': ['administrative_area_level_2',
                                                  'political']},
                                       {'long_name': 'New York',
                                        'short_name': 'NY',
                                        'types': ['administrative_area_level_1',
                                                  'political']},
                                       {'long_name': 'United States',
                                        'short_name': 'US',
                                        'types': ['country', 'political']}],
                'formatted_address': 'Manhattan, New York, NY, USA',
                'geometry': {'bounds': {'northeast': {'lat': 40.882214,
                                                      'lng': -73.907},
                                        'southwest': {'lat': 40.6795479,
                                                      'lng': -74.047285}},
                             'location': {'lat': 40.7902778,
                                          'lng': -73.9597222},
                             'location_type': 'APPROXIMATE',
                             'viewport': {'northeast': {'lat': 40.820045,
                                                        'lng': -73.90331300000001},
                                          'southwest': {'lat': 40.698078,
                                                        'lng': -74.03514899999999}}},
                'partial_match': True,
                'types': ['sublocality', 'political']}],
   'status': 'OK'}
  [
     {
        "lat": 40.7143528, 
        "lng": -74.00597309999999
     }, 
     {
        "lat": 40.7902778, 
        "lng": -73.9597222
     }
  ]
  </code></pre>
  
  <p>How Would I Be Able To Parse "Results" For Example? I would like to print out all the data within results.
  My Code Is...</p>
  
  <pre><code>import urllib, json
  import pprint
  
  URL2 = "http://maps.googleapis.com/maps/api/geocode/json?address=New+York&amp;sensor=false"
  
  googleResponse = urllib.urlopen(URL2)
  jsonResponse = json.loads(googleResponse.read())
  pprint.pprint(jsonResponse)
  test = json.dumps([s['geometry']['location'] for s in jsonResponse['results']], indent=3)
  print test['results']
  </code></pre>
  
  <p>the error I get is </p>
  
  <p>Traceback (most recent call last):</p>
  
  <p>File "C:/Python27/jstox.py", line 10, in </p>
  
  <p>print test['results']</p>
  
  <p>TypeError: string indices must be integers, not str</p>