Reputation: 41
I hava a 'abnormal' json file.
the file body like this
{
"_id" : ObjectId("aaaddd"),
"created_at" : ISODate("2017-05-26T18:04:31.315Z"),
"updated_at" : ISODate("2017-05-26T18:04:31.315Z"),
}
i have tried many ways to import this to mongo by pymongo, But i can not load the file body with json loader or bson loader. I know it is not a regular json or bson file.
But i use mongoimport import this file to mongodb successfully.
So does anyone know how to fix this and make it work?And how can i import this file to mongodb use pymongo?
Upvotes: 0
Views: 585
Reputation: 24009
Because the contents of that file are not JSON, they cannot be parsed by PyMongo's JSON parser. (PyMongo just uses the Python standard JSON parser to do most of the work.) Only mongoimport understands that file format, you must use mongoimport to load it into MongoDB.
If files like this one are part of your regular workflow, I recommend you create files that are standard JSON using mongoexport, instead of this non-JSON format.
Upvotes: 1