gpt4 book ai didi

Mongodb - Mongoimport 错误无效字符

转载 作者:行者123 更新时间:2023-12-02 02:29:11 26 4
gpt4 key购买 nike

我尝试使用 mongoimport 导入一个简单的 json 文件,但出现以下错误

PER-MacBook-Pro:/AJ$ mongoimport --db test --collection samplePM --file /users/AJ/Documents/Development/ETLwork/Dummydata/Penguin_Players.json
2015-06-16T09:53:57.291-0400 connected to: localhost
2015-06-16T09:53:57.293-0400 Failed: error processing document #1: invalid character '\\' looking for beginning of object key string
2015-06-16T09:53:57.293-0400 imported 0 documents

示例json文件如下:

      {  
"position":"Right Wing",
"id":8465166,
"weight":200,
"height":"6' 0\"",
"imageUrl":"http://1.cdn.nhle.com/photos/mugs/8465166.jpg",
"birthplace":"Seria, BRN",
"age":37,
"name":"Craig Adams",
"birthdate":"April 26, 1977",
"number":27
},
{
"position":"Right Wing",
"id":8475761,
"weight":195,
"height":"6' 2\"",
"imageUrl":"http://1.cdn.nhle.com/photos/mugs/8475761.jpg",
"birthplace":"Gardena, CA, USA",
"age":23,
"name":"Beau Bennett",
"birthdate":"November 27, 1991",
"number":19
}

我在这里做错了什么吗?

最佳答案

我能够使用 --jsonArray 标签,给出文件完整路径,并修改它在开头和结尾添加括号,

[{"my":"json","file":"imported"},{"my":"cool","file":"succeeded"}]

mongoimport --db myCoolDb --collection myCoolColl --file /path/to/my/imported/file.json --jsonArray

关于Mongodb - Mongoimport 错误无效字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30870155/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com