title: Python json.load missing array hook and parse callbacks?
body: <p>Why does <a href="https://docs.python.org/2/library/json.html" rel="nofollow noreferrer">json.loads</a>, only allow <code>object_hook</code>, <code>parse_float</code>, <code>parse_int</code> and <code>parse_constant</code>?</p>
  
  <pre><code>json.loads(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, **kw]]]]]]]])
  </code></pre>
  
  <p>They're all essentially callbacks, the return value of which is used during parsing.</p>
  
  <p>My intention was to use these callbacks to build my own representation of a JSON string by modifying the callback parameters. But without callbacks for arrays, strings or boolean - it seems rather limited.</p>
  
  <p>Take this simple example:</p>
  
  <pre><code>import json
  
  def _object_hook(d):
      print(d)
      return d
  
  json.loads('{"a": [1, [2, [3]]]}', object_hook=_object_hook)
  </code></pre>
  
  <p>...resulting in only a single call to _object_hook (since there is only one object).  </p>
  
  <pre><code>&gt;&gt;&gt; {u'a': [1, [2, [3]]]}
  </code></pre>
  
  <p>Give an arbitrarily deep, nested array, the job of passing the array (recursively, or perhaps with a breadth-first/depth-first traversal) remains.</p>
  
  <p>Then, strings are for some reason and exception too:</p>
  
  <pre><code>import json
  
  def _object_hook(o):
      print('_object_hook', o)
      return o
  
  def _parse_float(f):
      print('_parse_float', f)
      return f
  
  def _parse_int(i):
      print('_parse_int', i)
      return i
  
  def _parse_constant(c):
      print('_parse_constant', c)
      return c
  
  json.loads('{"a": [1, [2, [3.1], ["4"]]]}',
      object_hook=_object_hook,
      parse_int=_parse_int,
      parse_float=_parse_float,
      parse_constant=_parse_constant)
  </code></pre>
  
  <p>...there is no way to handle strings ("4" is omitted in the results below):</p>
  
  <pre><code>('_parse_int', '1')
  ('_parse_int', '2')
  ('_parse_float', '3.1')
  ('_object_hook', {u'a': ['1', ['2', ['3.1'], [u'4']]]})
  </code></pre>
  
  <p>Perhaps my expectations are wrong. But it seemed wasteful to parse a JSON string into a Python dict or list, only to parse it again into a custom format.</p>
  
  <p>With no array hooks or parse callbacks for strings, boolean, null, etc. Am I left with using <code>json.loads</code> and then parsing the resulting Python representation into my own Python classes?</p>