title: How to recursively find specific key in nested JSON?
body: <p>I'm trying to pull nested values from a json file. I want to print out each of the values for every "id" key. I think I'm close but can't figure out why the obj type changes from a dict to a list, and then why I'm unable to parse that list.
  Here is a link to the json I'm working with: <a href="http://hastebin.com/ratevimixa.tex">http://hastebin.com/ratevimixa.tex</a></p>
  
  <p>and here is my current code:</p>
  
  <pre><code>#!/usr/bin/env python
  #-*- coding: utf-8 -*-
  
  import json
  
  json_data = open('JubJubProductions.json', 'r+')
  jdata = json.loads(json_data.read().decode("utf-8"))
  
  def recursion(dict):
  
      for key, value in dict.items():
  
          if type(value) == type(dict):
              if key != "paging":
                  for key, value in value.items():
                      if isinstance (value,list):
                          print key
                          # place where I need to enter list comprehension?
                  if type(value) == type(dict):
                      if key == "id":
                          print " id found " + value
                      if key != "id":
                          print key + " 1st level"
                  if key == "id":
                      print key
          else:
              if key == "id":
                  print "id found " + value       
  if __name__ == '__main__':
      recursion(jdata)
  </code></pre>
  
  <h2>-------------------------------------------------------------------------------------------<strong>update</strong></h2>
  
  <p>This is now what I'm working with and it'll return a single id value, but not all of them:</p>
  
  <pre><code>#!/usr/bin/env python
  #-*- coding: utf-8 -*-
  
  import json
  
  json_data = open('jubjubProductions', 'r+')
  jdata = json.loads(json_data.read().decode("utf-8"))
  
  def id_generator(d):
      for k, v in d.items():
          if k == "id":
              yield v
          elif isinstance(v, dict):
              for id_val in id_generator(v):
                  yield id_val
  
  if __name__ == '__main__':
      for _ in id_generator(jdata):
          print (_)
  </code></pre>