javascript - Error importing BSON document, MongoDB -


i trying import sample bson file test.bson mongodb. server running, use

mongoimport --db test --collection foo --drop --file test.bson 

however, following error:

2016-01-24t13:51:06.126-0500    connected to: localhost 2016-01-24t13:51:06.144-0500    failed: error processing document #1: invalid character 'è' looking beginning of value 2016-01-24t13:51:06.144-0500    imported 0 documents 

(1) how 1 around error, invalid character 'è' looking beginning of value? should access data in test.bson?

(2) there other way import data using mongodb? if in shell , type

$mongo 

how can import json/bson files?

(bson binary representation of json additional type information.)

i think need mongorestore instead of mongoimport. try

mongorestore --db test --collection foo --drop test.bson 

from docs:

warning:

avoid using mongoimport , mongoexport full instance production backups. not reliably preserve rich bson data types, because json can represent subset of types supported bson. use mongodump , mongorestore described in mongodb backup methods kind of functionality.

mongoimport , mongoexport used json-like representations of data (although works csv , tsv). mongorestore , mongoexport bson.


Comments