title: Is there a way to override python's json handler?
body: <p>I'm having trouble encoding infinity in json.</p>
  
  <p><code>json.dumps</code> will convert this to <code>"Infinity"</code>, but I would like it do convert it to <code>null</code> or another value of my choosing.</p>
  
  <p>Unfortunately, setting <code>default</code> argument only seems to work if dumps does't already understand the object, otherwise the default handler appears to be bypassed.</p>
  
  <p>Is there a way I can pre-encode the object, change the default way a type/class is encoded, or convert a certain type/class into a different object prior to normal encoding?</p>