title: Accessing nested json objects using python
body: <p>I am trying to interact with an API and running into issues accessing nested objects. Below is sample json output that I am working with. </p>
  
  <pre><code>{
      "results": [
          {
              "task_id": "22774853-2b2c-49f4-b044-2d053141b635",
              "params": {
                  "type": "host",
                  "target": "54.243.80.16",
                  "source": "malware_analysis"
              },
              "v": "2.0.2",
              "status": "success",
              "time": 227,
              "data": {
                  "details": {
                      "as_owner": "Amazon.com, Inc.",
                      "asn": "14618",
                      "country": "US",
                      "detected_urls": [],
                      "resolutions": [
                          {
                              "hostname": "bumbleride.com",
                              "last_resolved": "2016-09-15 00:00:00"
                          },
                          {
                              "hostname": "chilitechnology.com",
                              "last_resolved": "2016-09-16 00:00:00"
                          }
                      ],
                      "response_code": 1,
                      "verbose_msg": "IP address in dataset"
                  },
                  "match": true
              }
          }
      ]
  }
  </code></pre>
  
  <p>The deepest I am able to access is the data portion which returns too much.... ideally I am just trying access as_owner,asn,country,detected_urls,resolutions</p>
  
  <p>When I try to access details / response code ... etc I will get a KeyError. My nested json goes deeper then other Q's mentioned and I have tried that logic. </p>
  
  <p>Below is my current code snippet and any help is appreciated!</p>
  
  <pre><code>import requests
  import json
  headers = {
     'Content-Type': 'application/json',
  }
  
  params = (
     ('wait', 'true'),
  )
  
  data = '{"target":{"one":{"type": "ip","target": "54.243.80.16", "sources": ["xxx","xxxxx"]}}}'
  
  r=requests.post('https://fakewebsite:8000/api/services/intel/lookup/jobs', headers=headers, params=params, data=data, auth=('apikey', ''))
  parsed_json = json.loads(r.text)
  #results = parsed_json["results"]
  for item in parsed_json["results"]:
       print(item['data'])
  </code></pre>