MongoDB-Mongoimport错误无效字符 [英] Mongodb - Mongoimport error invalid character

查看:177
本文介绍了MongoDB-Mongoimport错误无效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried to import a simple json file using mongoimport and i get the following error

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文件如下:

Sample json file is as follows:

      {  
         "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
      }

我在这里做错什么了吗?

Am I doing something wrong here?

推荐答案

有关非"UTF-8"字符的注释很有帮助.

The comment about non "UTF-8" characters was helpful.

在Mac中使用textedit创建json文档似乎存在问题.我找不到这些非UTF-8字符,但是我在Mac Shell中使用vi test.json创建了相同的文件.我粘贴了内容,保存了文件并使用了mongoimport.现在可以使用了.

It seems like there is a problem with creating json documents using textedit in Mac. I could not find these non UTF-8 characters but i created the same file using vi test.json in mac shell. I pasted the contents, saved the file and used mongoimport. It works now.

谢谢

这篇关于MongoDB-Mongoimport错误无效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆