title: How do I make a graph of custom json deserializers in Python
body: <p><a href="http://broadcast.oreilly.com/2009/05/pymotw-json.html" rel="nofollow">http://broadcast.oreilly.com/2009/05/pymotw-json.html</a> gives a helpful introduction to the use of a hook function to control how json objects can be mapped to specific python classes.</p>
  
  <p>It's not evident to me how to extend this to deeper graphs. Consider something like:</p>
  
  <pre><code>{
    "list_of_x": {
        "type": "x",
        "items" : [
          { "key" : "value" },
          { "key" : "value" }
        ]
    }
  }
  </code></pre>
  
  <p>I want to map the outer object to one python class, and the inner objects in the list to another python class, using <code>JSONDecoder</code> and the <code>object_hook</code>. When the hook is called 'down below', how can I see the value of the <code>type</code> slot above? Or, in cases where there's no type, because there's only one possible type, how do I know where I am to use it?</p>