title: Opening a Json File From Google API's In Python3
body: <p>I would like to open a json file in python as an object that I can manipulate and work with</p>
  
  <p>I have a json file than contains text like the following</p>
  
  <pre><code>{'geocoded_waypoints': [{'geocoder_status': 'OK', 'place_id': 'ChIJtxsqpbgEdkgRSCY1a5fQpDA', 'types': ['airport', 'establishment', 'point_of_interest']}, {'geocoder_status': 'OK', 'place_id': 'ChIJdd4hrwug2EcRmSrV3Vo6llI', 'types': ['locality', 'political']}], 'routes': ......
  </code></pre>
  
  <p>...</p>
  
  <p>I received this json text from the google transit api, <a href="https://stackoverflow.com/questions/39491420/python-jsonexpecting-property-name-enclosed-in-double-quotes/39491613">I know that json doesn't look like the above text</a>, but that's what google transit gives me so thats what I have to work with.</p>
  
  <p>I've tried <a href="http://developer.rhino3d.com/guides/rhinopython/python-xml-json/" rel="nofollow noreferrer">this method</a>,</p>
  
  <pre><code>&gt;&gt;&gt; data = json.load(open('gmap_routes.json'))
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 299, in load
      parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
      return _default_decoder.decode(s)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 355, in raw_decode
      obj, end = self.scan_once(s, idx)
  json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
  </code></pre>
  
  <p>And <a href="https://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file">this method</a> where I tried to fix the unicode characters in it but it would not work</p>
  
  <pre><code>&gt;&gt;&gt; import json
  &gt;&gt;&gt; with open("gmap_routes.json") as f:
  ...     json.load(f.encode("ascii","replace"))
  ... 
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 2, in &lt;module&gt;
  AttributeError: '_io.TextIOWrapper' object has no attribute 'encode'
  </code></pre>
  
  <p>I also tried python2 for a while and got similar results, so I just went back to python3</p>