Cannot import a json in MongoDB

亡梦爱人 提交于 2020-01-24 22:41:25

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/22733243/cannot-import-a-json-in-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!