title: Iterate through nested JSON object and get values throughout
body: <p>Working on a API project, in which I'm trying to get all the redirect urls from an API output such as <a href="https://urlscan.io/api/v1/result/39a4fc22-39df-4fd5-ba13-21a91ca9a07d/" rel="nofollow noreferrer">https://urlscan.io/api/v1/result/39a4fc22-39df-4fd5-ba13-21a91ca9a07d/</a></p>
  <p>Example of where I'm trying to pull the urls from:</p>
  <pre><code>&quot;redirectResponse&quot;: {
    &quot;url&quot;: &quot;https://www.coke.com/&quot;
  </code></pre>
  <p>I currently have the following code:</p>
  <pre><code>import requests
  import json
  import time
  
  #URL to be scanned
  url = 'https://www.coke.com'
  
  #URL Scan Headers
  headers = {'API-Key':apikey,'Content-Type':'application/json'}
  data = {&quot;url&quot;:url, &quot;visibility&quot;: &quot;public&quot;}
  response = requests.post('https://urlscan.io/api/v1/scan/',headers=headers, data=json.dumps(data))
  
  uuid = response.json()['uuid']
  responseUrl = response.json()['api']
  
  time.sleep(10)
  
  req = requests.Session()
  r = req.get(responseUrl).json()
  r.keys()
  
  for value in  r['data']['requests']['redirectResponse']['url']:
      print(f&quot;{value}&quot;)
  
  </code></pre>
  <p>I get the following error: <code>TypeError: list indices must be integers or slices, not str</code>. Not sure what the best way to parse the nested json in order to get all the redirect urls.</p>