title: Why do int keys of a python dict turn into strings when using json.dumps?
body: <p>According to <a href="http://docs.python.org/2/library/json.html#py-to-json-table" rel="noreferrer">this conversion table</a>, Python ints get written as JSON numbers when serialized using the JSON module--as I would expect and desire.</p>
  
  <p>I have a dictionary with an integer key and integer value:</p>
  
  <pre><code>&gt;&gt;&gt; d = {1:2}
  &gt;&gt;&gt; type(d.items()[0][0])
  &lt;type 'int'&gt;
  &gt;&gt;&gt; type(d.items()[0][1])
  &lt;type 'int'&gt;
  </code></pre>
  
  <p>When I use the json module to serialize this to a JSON string, the value is written as a number, but the key is written as a string:</p>
  
  <pre><code>&gt;&gt;&gt; json.dumps(d)
  '{"1": 2}'
  </code></pre>
  
  <p>This isn't the behavior I want, and it seems particularly broken since it breaks json.dumps/json.loads round-tripping:</p>
  
  <pre><code>&gt;&gt;&gt; d == json.loads(json.dumps(d))
  False
  </code></pre>
  
  <p>Why does this happen, and is there a way I can force the key to be written as a number?</p>