IvanErlic2000 IvanErlic2000 - 2 months ago 18
JSON Question

Error importing JSON file into mongoDB

I tried importing a JSON file into mongo db using this command.

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


But I get this message:

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


After an hour searching for that ',' I cant find it.

This is my JSON file:

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


Can someone please help me find the error. Thank you!

Answer

Have a look at day7

"day7", {
  "rest": true
}

should be

"day7": {
  "rest": true
}
Comments