Here's some code you can use to process the output of mongoexport
yourself in C#:
var server = MongoServer.Create("mongodb://localhost/?safe=true");
var database = server["test"];
var collection = database["test"];
using (var streamReader = new StreamReader("test.json")) {
using (var bsonReader = BsonReader.Create(streamReader)) {
while (bsonReader.CurrentBsonType !=
BsonType.EndOfDocument) {
var document = BsonDocument.ReadFrom(bsonReader);
collection.Insert(document);
}
}
}
What the code is doing is reading one BsonDocument at a time from the
BsonReader until there are no more left.
Not sure how mongoexport handles international character sets, so if
your data contains strings with international character sets you may
need to worry about character encodings.
There is one really important limitation: the entire file is loaded
into memory when the BsonReader is created. This is fine for small or
medium files, but if the file is humongous you could have problems.