MongoDB数据库;未捕获的异常:SyntaxError:属性列表后缺少 }:

MongoDB; Uncaught exception: SyntaxError: missing } after property list :

提问人:FoliFF 提问时间:5/5/2022 更新时间:5/6/2022 访问量:117

问:

目前正在尝试非关系数据库和MongoDB,我正在向我的数据库添加一个电影列表。但是,每次添加电影时,我都会收到此错误: 未捕获的异常:SyntaxError:属性列表后缺少 }: @(外壳):6:309

我不明白,我不明白,因为我有正确数量的“}”。这是我尝试做的一个示例,但出现错误:

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
数据库 mongoDB 语法错误

评论


答:

0赞 DFW 5/6/2022 #1

我在当地尝试了一下,我认为你有一些对我不起作用的东西。我建议逐行尝试,看看什么有效并导致它失败。

  1. 显然必须更换...带有某种格式的空格
  2. 我需要将“和”替换为”。当我没有这样做时,即使只有标题,Mongo playground 也会抱怨。https://mongoplayground.net/p/EwYYx11rPyS
  3. 一旦我做了那个替换,我就不得不在围绕“思想文学”的文本中逃避你想要的“字符”。

这对我来说很好:https://mongoplayground.net/p/hhKpK35Cut7

评论

0赞 FoliFF 5/6/2022
是的,这就是 3 的问题。谢谢!
0赞 Mbay 5/6/2022 #2

当您忘记冒号或逗号或混合引号时,通常会发生此错误。

我认为引述了导致这种情况的原因。你能把它改成单引号吗?“literature of ideas”

评论

0赞 FoliFF 5/6/2022
谢谢伙计,这就是问题所在。当我使用另一个编辑器时,我注意到了。