title: How to parse values from JSON in Python
body: <p>Good morning; I'm trying to pull some key values from the URL generated JSON file.</p>
  
  <p>I'm able to pull the JSON from the URL without issues (line 8 is printed for reference)</p>
  
  <pre><code>def get_url():
      api_conditions_url = 'http://magicseaweed.com/api/' + API_KEY + '/forecast/?spot_id=' + PUTSBOROUGH_SPOT_ID
      print('Collecting data from - ' + api_conditions_url)
      try:
          f = urlopen(api_conditions_url)
      except:
          return []
      json_currently = f.read()
      print(json_currently)
      f.close()
      return json.loads(json_currently)
  
  def main():
      curr_conditions = get_url()
      if ("absMinBreakingHeight" not in curr_conditions["swell"]):
          print ("Error #001 JSON call failed, check your query is correct!]\n")
          exit()
      else:
          print('it worked')
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <hr>
  
  <p>The JSON file looks like the below: </p>
  
  <hr>
  
  <pre><code>{  
        "timestamp":1564617600,
        "localTimestamp":1564617600,
        "issueTimestamp":1564617600,
        "fadedRating":0,
        "solidRating":0,
        "swell":{  
           "absMinBreakingHeight":1.3,
           "absMaxBreakingHeight":2.03,
           "probability":100,
           "unit":"ft",
           "minBreakingHeight":1,
           "maxBreakingHeight":2,
           "components":{  
              "combined":{  
                 "height":3,
                 "period":6,
                 "direction":75.97,
                 "compassDirection":"WSW"
              },
              "primary":{  
                 "height":2.5,
                 "period":6,
                 "direction":65.06,
                 "compassDirection":"WSW"
              },
              "secondary":{  
                 "height":1.1,
                 "period":6,
                 "direction":160.71,
                 "compassDirection":"NNW"
              }
           }
        },
        "wind":{  
           "speed":5,
           "direction":127,
           "compassDirection":"NW",
           "chill":60,
           "gusts":6,
           "unit":"mph"
        },
        "condition":{  
           "pressure":1017,
           "temperature":61,
           "weather":"10",
           "unitPressure":"mb",
           "unit":"f"
        },
        "charts":{  
           "swell":"https:\/\/charts-s3.msw.ms\/archive\/wave\/750\/1-1564617600-1.gif",
           "period":"https:\/\/charts-s3.msw.ms\/archive\/wave\/750\/1-1564617600-2.gif",
           "wind":"https:\/\/charts-s3.msw.ms\/archive\/gfs\/750\/1-1564617600-4.gif",
           "pressure":"https:\/\/charts-s3.msw.ms\/archive\/gfs\/750\/1-1564617600-3.gif",
           "sst":"https:\/\/charts-s3.msw.ms\/archive\/sst\/750\/1-1564617600-10.gif"
        }
     },
  </code></pre>
  
  <hr>
  
  <p>I receive the following error when trying to parse the JSON file - </p>
  
  <pre><code>if ("absMinBreakingHeight" not in curr_conditions["swell"]):
  </code></pre>
  
  <blockquote>
    <p>TypeError: list indices must be integers or slices, not str"</p>
  </blockquote>