mongoimport期间发生错误 [英] Error during mongoimport
问题描述
我有几个有效的JSON文档,我尝试将它们导入mongodb中.
I have a couple of valid JSON documents and I try to import them in mongodb.
{ "Books":
[{ "ISBN":"ISBN-0-13-713526-2",
"Price":85,
"Edition":3,
"Title":"A First Course in Database Systems",
"Authors":[ {"First_Name":"Jeffrey", "Last_Name":"Ullman"},
{"First_Name":"Jennifer", "Last_Name":"Widom"} ] }
,
{ "ISBN":"ISBN-0-13-815504-6",
"Price":100,
"Remark":"Buy this book bundled with 'A First Course' - a great deal!",
"Title":"Database Systems:The Complete Book",
"Authors":[ {"First_Name":"Hector", "Last_Name":"Garcia-Molina"},
{"First_Name":"Jeffrey", "Last_Name":"Ullman"},
{"First_Name":"Jennifer", "Last_Name":"Widom"} ] }],
"Magazines":
[{ "Title":"National Geographic",
"Month":"January",
"Year":2009 }
,
{ "Title":"Newsweek",
"Month":"February",
"Year":2009 },
{"Title": "Newsweek"}]
}
我遇到以下错误:
Sun Mar 24 15:23:27例外:提供的JSON的BSON表示为 太大:无法解析附近的JSON字符串:月":"J Sun Mar 24
Sun Mar 24 15:23:27 exception:BSON representation of supplied JSON is too large: Failure parsing JSON string near: "Month":"J Sun Mar 24
15:23:27异常:提供的JSON的BSON表示太大: 无法解析附近的JSON字符串:年":200 Sun Mar 24 15:28:23
15:23:27 exception:BSON representation of supplied JSON is too large: Failure parsing JSON string near: "Year":200 Sun Mar 24 15:28:23
错误:遇到28个错误
有人可以说出什么问题吗?
Could someone say what's wrong?
推荐答案
默认情况下,mongoimport
期望每个文档都位于JSON文件的一行中.您需要使用所使用的格式将--jsonArray
传递给mongoimport
,或者只是确保单个文档的所有数据都在一行上.
By default mongoimport
expects that each document will be on a single line of the JSON file. You need to pass --jsonArray
to mongoimport
using the format you're using, or just make sure that all of the data for a single document is on one line.
(我按原样保存了文件,添加了--jsonArray
选项,它运行良好.)
(I saved your file, as is, added the --jsonArray
, option and it worked fine.)
这篇关于mongoimport期间发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!