将JSON文件导入mongoDB时出错

时间:2016-09-05 09:57:21

标签: json mongodb mongoimport

我尝试使用此命令将JSON文件导入mongo db。

mongoimport --db test --collection workouts --type json --file /Users/ivanerlic/Documents/Programming/Projects/fitness-app/workouts/4Days/45Min/intermediate/gainMuscle/workout.json

但是我收到了这条消息:

connected to: localhost
Failed: error processing document #1: invalid character ',' after object key
imported 0 documents

一小时后搜索','我找不到。

这是我的JSON文件:

{
  "days": 4,
  "minutes": 45,
  "experience": "intermediate",
  "goal": "gain muscle",
  "workout": {
    "day1": {
      "rest": false,
      "group": "Chest",
      "exerciseCount": 4,
      "exercise1": {
        "name": "Bench Press",
        "sets": 4,
        "reps": 8
      },
      "exercise2": {
        "name": "Incline Dumbbell Press",
        "sets": 4,
        "reps": 10
      },
      "exercise3": {
        "name": "Incline Dumbbell Fly",
        "sets": 4,
        "reps": 15
      },
      "exercise4": {
        "name": "Cable Fly",
        "sets": 3,
        "reps": 15
      }
    },
    "day2": {
      "rest": true
    },
    "day3": {
      "rest": false,
      "group": "Back",
      "exerciseCount": 4,
      "exercise1": {
        "name": "Lat Pulldown",
        "sets": 4,
        "reps": 12
      },
      "exercise2": {
        "name": "Bent-over Row",
        "sets": 4,
        "reps": 8
      },
      "exercise3": {
        "name": "T-bar Row",
        "sets": 4,
        "reps": 10
      },
      "exercise4": {
        "name": "One-arm Dumbbell Row",
        "sets": 4,
        "reps": 10
      }
    },
    "day4": {
      "rest": true
    },
    "day5": {
      "rest": false,
      "group": "Shoulders and Arms",
      "exerciseCount": 5,
      "exercise1": {
        "name": "Military Press",
        "sets": 4,
        "reps": 8
      },
      "exercise2": {
        "name": "Lateral Raise",
        "sets": 3,
        "reps": 10
      },
      "exercise3": {
        "name": "Rear Shoulder Fly",
        "sets": 3,
        "reps": 12
      },
      "exercise4": {
        "name": "Dumbbell Curl",
        "sets": 3,
        "reps": 12
      },
      "exercise5": {
        "name": "Rope Pushdown",
        "sets": 3,
        "reps": 12
      }
    },
    "day6": {
      "rest": false,
      "group": "Legs",
      "exerciseCount": 5,
      "exercise1": {
        "name": "Military Press",
        "sets": 4,
        "reps": 8
      },
      "exercise2": {
        "name": "Lateral Raise",
        "sets": 3,
        "reps": 10
      },
      "exercise3": {
        "name": "Rear Shoulder Fly",
        "sets": 3,
        "reps": 12
      },
      "exercise4": {
        "name": "Dumbbell Curl",
        "sets": 3,
        "reps": 12
      },
      "exercise5": {
        "name": "Rope Pushdown",
        "sets": 3,
        "reps": 12
      }
    },
    "day7", {
      "rest": true
    }
  }
}

有人可以帮我找错。谢谢!

1 个答案:

答案 0 :(得分:3)

查看day7

"day7", {
  "rest": true
}

应该是

"day7": {
  "rest": true
}