title: How to parse JSON data from API response in Python?
body: <p>I am trying to write a script that will pull current status from our monitoring tools and update them in MS SQL DB. When I call the API I get a HUGE response in JSON format:</p>
  
  <pre><code>{
    "hoststatuslist": {
      "recordcount": "1084",
      "hoststatus": [
        {
          "@attributes": {
            "id": "XXXX"
          },
          "host_id": "XXX",
          "name": "XXXXX",
          "display_name": "XXXXXXX",
          "address": "XXXXXX",
          "alias": "XXXXXX",
          "status_text": "XXXXXXXXXXXXXXXXXXXXXXX",
          etc.
        },
        {
          "@attributes": {
            "id": "XXXX"
          },
          "host_id": "XXX",
          "name": "XXXXX",
          "display_name": "XXXXXXX",
          "address": "XXXXXX",
          "alias": "XXXXXX",
          "status_text": "XXXXXXXXXXXXXXXXXXXXXXX",
          etc.
        },
        etc.
      ]
    }
  }
  </code></pre>
  
  <p>As you can see I get over 1000 host objects with attributes. I want to parse the response, so that I can add/update the MS SQL DB. I'm trying to parse out the <em>host_id</em>, <em>name</em>, and <em>status_text</em> for each host.</p>
  
  <p>I tried to do something like this <a href="https://stackoverflow.com/questions/16675849/python-parsing-json-data-set">Python - Parsing JSON Data Set</a> but I keep getting errors that the response object has no attribute read or decode.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>import requests
  import json
  
  response = requests.get('url with API Key')
  decoded_response = response.read().decode("UTF-8")
  data = json.loads(decoded_response)
  jsonData = data["hoststatus"]
  
  for host in jsonData:
      Name = host.get("name")
      StatusText = host.get("status_text")
  </code></pre>
  
  <p>If anyone has a suggestion to do this with another language or tool I am open. I need to call about 20 APIs and put all the status/other information into a DB so that it's all in one location.</p>
  
  <p>Any help is appreciated.</p>