Home > other >  MongoDB; Uncaught exception: SyntaxError: missing } after property list :
MongoDB; Uncaught exception: SyntaxError: missing } after property list :

Time:05-06

Currently trying out Non-Relational Databases & MongoDB and I am adding a movie list to my db. However, every time I add my movie I get this error: uncaught exception: SyntaxError: missing } after property list : @(shell):6:309

I don’t understand I don’t since I have correct amount of “}”. Here is an example I’m trying to do but getting the error on:

var movie2 = {
… Title: “Inception”,
… Description: “A thief who steals corporate secrets through the use of dream-sharing technology is given the inverse task of planting an idea into the mind of a C.E.O., but his tragic past may doom the project and his team to disaster.”,
… Genre: {
… Name: “Sci-Fi”,
… Description: “Science fiction (sometimes shortened to sci-fi or SF) is a genre of speculative fiction which typically deals with imaginative and futuristic concepts such as advanced science and technology, space exploration, time travel, parallel universes, and extraterrestrial life. It has been called the “literature of ideas”, and it often explores the potential consequences of scientific, social, and technological innovations.”
… },
… Director: {
… Name: “Christopher Nolan”,
… Bio: “Best known for his cerebral, often nonlinear, storytelling, acclaimed writer-director.”,
… Birth: “1970-07-30”
… },
… ImagePath: “Inception (2010)”,
… Featured: true
… }
uncaught exception: SyntaxError: missing } after property list :
@(shell):6:309

CodePudding user response:

This error usually occurs when you forget a colon or comma or you have mixing quotes.

I think quotes on the “literature of ideas” causing this. Can you change it to single quotes?

CodePudding user response:

I tried this out locally and I think you've got a few things that didn't work for me. I'd suggest trying it out line by line and see what works and causes it to fail.

  1. Obviously had to replace the ... with a whitespaces of some format
  2. I needed to replace the “ and ” with ". When I didn't, even with the only the title, Mongo playground complained. https://mongoplayground.net/p/EwYYx11rPyS
  3. Once I did that replacement, I had to escape your intended " characters in the text surrounding "literature of ideas".

This worked fine for me: https://mongoplayground.net/p/hhKpK35Cut7

  • Related