mongodb 未按预期导入 json [英] mongodb not importing json as expected

查看:50
本文介绍了mongodb 未按预期导入 json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试用这个导入 json

I've been trying to import a json with this

mongoimport --upsert --db mydb --jsonArray --file AllCards.json

但我得到的是

导入了 0 个对象"

我得到一个包含 0 个元素的数据库.

I get a db with 0 elements.

当我使用 JSON 查看器加载相同的 JSON 文件时,它会被正确读取.

The same JSON file is properly read when i load it with a JSON viewer.

这是我收到的错误消息的一部分

This is part of the error message i get

异常:传递给 mongoimport 的 JSON 无效:代码 FailedtoParse:>FailedtoParse:Excpecting '{': offset:0 of :

exception: Invalid JSON passed to mongoimport: code FailedtoParse: >FailedtoParse: Excpecting '{': offset:0 of :

我尝试导入的 JSON 文件有 6MB,但我一直在对其进行修剪以试图找出问题所在.即使使用此内容,问题仍然存在:

The JSON file I'm trying to import has 6MB, but I have been trimming it to try to find the problem. The problem persists even with this content:

{
  "Air Elemental": {
    "layout": "normal",
    "name": "Air Elemental",
    "manaCost": "{3}{U}{U}",
    "cmc": 5,
    "colors": ["Blue"],
    "type": "Creature — Elemental",
    "types": ["Creature"],
    "subtypes": ["Elemental"],
    "text": "Flying",
    "power": "4",
    "toughness": "4",
    "imageName": "air elemental",
    "colorIdentity": ["U"]
  },
  "Ancestral Recall": {
    "layout": "normal",
    "name": "Ancestral Recall",
    "manaCost": "{U}",
    "cmc": 1,
    "colors": ["Blue"],
    "type": "Instant",
    "types": ["Instant"],
    "text": "Target player draws three cards.",
    "mciNumber": "1",
    "imageName": "ancestral recall",
    "colorIdentity": ["U"]
  }
}

推荐答案

我正在做 mongoimport --upsert --db jason --collection contacts --file omuk.json它工作正常.找到了:

I am doing it mongoimport --upsert --db jason --collection contacts --file omuk.json And it is working fine. Found it:

2016-04-05T14:34:19.305+0600    connected to: localhost
2016-04-05T14:34:19.314+0600    imported 1 document

这篇关于mongodb 未按预期导入 json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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