【发布时间】:2018-03-31 10:43:39
【问题描述】:
所以我想将我电脑上的数据库的数据在线添加到mlab数据库中。我复制了数据(我假设是 JSON)并尝试将其粘贴到我的 mlab 数据库中的集合中。
现在,问题是我的数据库中的 ObjectIds 导致错误,因为它不是有效的 JSON。有谁知道如何解决这个问题?
示例文档
{
"_id" : ObjectId("5a8ae78844a5ba0d448a4cf7"),
"ratings" : [],
"reviews" : [],
"title" : "The Shape of Water",
"director" : "Guillermo Del Toro",
"length" : 123,
"genre" : "Drama",
"description" : "At a top secret research facility in the 1960s, a lonely janitor forms a unique relationship with an amphibious creature that is being held in captivity.",
"actors" : "French chick, Fish Dude",
"year" : 2018,
"pictureUrl" : "https://media.pathe.nl/nocropthumb/620x955/gfx_content/other/api/filmdepot/v1/movie/download/23452_94164_ps_sd-high.jpg",
"__v" : 18,
"averageRating" : 4
}
Mlab 错误
JSON 验证错误 close 我们在解析您的文件时遇到错误 JSON。请检查您的语法(例如,确保您使用的是 double 将您的字段名称和值都用引号引起来),然后重试。
我在 JSON lint 中测试了代码,它给了我这个错误:
Error: Parse error on line 2:
{ "_id": ObjectId("5a69cc1f90
---------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
【问题讨论】: