title: How can I use Python to transform MongoDB's bsondump into JSON?
body: <p>So I have an enormous quantity of .bson from a MongoDB dump. I am using <a href="http://docs.mongodb.org/manual/reference/bsondump/">bsondump</a> on the command line, piping the output as stdin to python. This successfully converts from BSON to 'JSON' but it is in fact a string, and seemingly not legal JSON.</p>
  
  <p>For example an incoming line looks like this:</p>
  
  <pre><code>{ "_id" : ObjectId( "4d9b642b832a4c4fb2000000" ),
    "acted_at" : Date( 1302014955933 ),
    "created_at" : Date( 1302014955933 ),
    "updated_at" : Date( 1302014955933 ),
    "_platform_id" : 3,
    "guid" : 72106535190265857 }
  </code></pre>
  
  <p>Which I belive is <a href="http://www.mongodb.org/display/DOCS/Mongo+Extended+JSON">Mongo Extended JSON</a>. </p>
  
  <p>When I read in such a line and do:</p>
  
  <pre><code>json_line = json.dumps(line)
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>"{ \"_id\" : ObjectId( \"4d9b642b832a4c4fb2000000\" ),
  \"acted_at\" : Date( 1302014955933 ),
  \"created_at\" : Date( 1302014955933 ),
  \"updated_at\" : Date( 1302014955933 ),
  \"_platform_id\" : 3,
  \"guid\" : 72106535190265857 }\n"
  </code></pre>
  
  <p>Which is still <code>&lt;type 'str'&gt;</code>.</p>
  
  <p>I have also tried</p>
  
  <pre><code>json_line = json.dumps(line, default=json_util.default)
  </code></pre>
  
  <p>(see pymongo json_util - spam detection prevents a third link )
  Which seems to output the same as dumps above. loads gives an error:</p>
  
  <pre><code>json_line = json.loads(line, object_hook=json_util.object_hook)
  ValueError: No JSON object could be decoded
  </code></pre>
  
  <p>So, how can I transform the string of TenGen JSON into parseable JSON? 
  (the end goal is to stream tab separated data to another database)</p>