Cannot import a json in MongoDB

2019-07-31 10:38发布

I am using RockMongo in Openshift to import a json file in MongoDB database. I exported directly the json from another MongoDB and I haven't changed anything. Here is a part of the json:

{ "_id" : "10352",
 "author" : "8988607", 
"country" : "...",
 "views" : 1716,
 "title" : "...", 
"comments" : 1, 
"likes" : 28, 
"text" : "...", 
"date" : { "$date" : 1278070740000 }, 
"approved" : "8480596" }

And I have this error message:

exception: field names cannot start with $ [$date] at src/mongo/shell/collection.js:147

As I said, I exported the json directly from another MongoDB. How can I solve this problem now?

2条回答
Luminary・发光体
2楼-- · 2019-07-31 11:11

MongoDB uses its Extended JSON. Rockmongo likely uses a standard JSON parser, thus the mismatches.

Can you use the provided mongoimport application? You will need to use v2.4.0 or greater to include all the extended types see: SERVER-5675

查看更多
We Are One
3楼-- · 2019-07-31 11:13

I came up against this problem and my dba replaced the dollar sign with \uFF04 and that did the trick for us.

查看更多
登录 后发表回答