title: How to dump a Python dictionary to JSON when keys are non-trivial objects?
body: <pre><code>import datetime, json
  x = {'alpha': {datetime.date.today(): 'abcde'}}
  print json.dumps(x)
  </code></pre>
  
  <p>The above code fails with a <code>TypeError</code> since keys of JSON objects need to be strings. The <code>json.dumps</code> function has a parameter called default that is called when the <em>value</em> of a JSON object raises a <code>TypeError</code>, but there seems to be no way to do this for the <em>key</em>. What is the most elegant way to work around this?</p>