Cannot json dump a python dictionary with id key
Question: 
    json.dump({'id' : '3'})
    
      File "/Library/Python/2.7/site-packages/simplejson/__init__.py", line 354, in dumps
        return _default_encoder.encode(obj)
      File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 262, in encode
        chunks = self.iterencode(o, _one_shot=True)
      File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 340, in iterencode
        return _iterencode(o, 0)
      File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 239, in default
        raise TypeError(repr(o) + " is not JSON serializable")
    TypeError: ObjectId('520183b519744a0ca3d36003') is not JSON serializable
    

What is wrong?


Answer: Try using the standard json library and `dumps` instead.

With that change it works fine for me.

    
    
    >>> import json
    >>> json.dumps({'id' : '3'})
    '{"id": "3"}'
    

