Closed ShaneHarvey closed 2 years ago
@ShaneHarvey is there any further work for this? #15 is resolved.
Yes, there is more work to do. We need to actually take advantage of the new libbson APIs that generate extended JSON 2.0. Right now we use bson_as_json
, we need to expose the bson_as_canonical_extended_json
and/or bson_as_relaxed_extended_json
methods.
@ShaneHarvey I'm looking to use python-bsonjs to take documents from a pymongo cursor, decode those to JSON, and write them out locally to a single JSON file. I'm having a hard time finding documentation on how to do this using python-bsonjs. Any suggestions?
Hi @averhagen . You can do something like this:
from pymongo import MongoClient
from bson.raw_bson import RawBSONDocument
import bsonjs
with open('myfile.json', 'w') as f:
client = MongoClient('<connection_string>', document_class=RawBSONDocument)
for raw_doc in client.mydb.mycoll.find('<query>'):
f.write(bsonjs.dumps(raw_doc.raw))
@juliusgeo - see @ShaneHarvey's comment above about the scope of work for this.
Once libbson 1.7.0 is released with MongoDB Extended JSON 2.0 support we can add support here as well. See https://jira.mongodb.org/browse/CDRIVER-2128.