title: JSON serialize a dictionary with tuples as key
body: <p>Is there a way in Python to serialize a dictionary that is using a tuple as key?</p>
  <p>e.g.</p>
  <pre><code>a = {(1, 2): 'a'}
  </code></pre>
  <p>simply using <code>json.dumps(a)</code> raises this error:</p>
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;/usr/lib/python2.6/json/__init__.py&quot;, line 230, in dumps
      return _default_encoder.encode(obj)
    File &quot;/usr/lib/python2.6/json/encoder.py&quot;, line 367, in encode
      chunks = list(self.iterencode(o))
    File &quot;/usr/lib/python2.6/json/encoder.py&quot;, line 309, in _iterencode
      for chunk in self._iterencode_dict(o, markers):
    File &quot;/usr/lib/python2.6/json/encoder.py&quot;, line 268, in _iterencode_dict
      raise TypeError(&quot;key {0!r} is not a string&quot;.format(key))
  TypeError: key (1, 2) is not a string
  </code></pre>