JSON-LD缺少'}'或对象成员名称.错误

sud*_*vel 9 json json-ld

我想在之前将json-ld添加到我的网站,我想将它添加到我的开发站点进行测试

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "xxxxxxxxxxxxxxxx",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+xx-xxx-xxx-xxxx",
    "contactType": "customer service"

  }]
}
</script>
Run Code Online (Sandbox Code Playgroud)

我收到错误,指出Missing'}'或对象成员名称.什么是这个错误,我已正确关闭括号.如何修复它,请帮助

P-S*_*P-S 27

通常此错误是由于不需要的逗号,请确保从每个{}块中的所有最后元素中删除尾随逗号.

示例代码段:

<script type="application/ld+json">
{
    "@context": "http://schema.org",
    "@type": "Article",
    "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "http://foo.bar", // Remove comma here
    }, // Remove comma here

    // Add other required fields if necessary
}
</script>
Run Code Online (Sandbox Code Playgroud)

  • 另外,这应该是根据所问问题接受的答案 (2认同)

Mar*_*ler 5

该代码段是完全可以的。它既是有效的JSON,又是有效的JSON-LD。您可以使用JSON-LD游乐场Google的结构化数据测试工具对其进行测试


小智 5

我遇到了完全相同的问题。JSON-LD 标记与最后一个元素后面的逗号等无关。您的绝对正确。

但请注意,''Google 不接受单引号或单引号。您必须对""每个键和值使用双引号或,包括数组中的元素而不是数组本身。


ele*_*ser 5

我遇到了同样的问题,并发现了错误的不寻常原因。就我而言,未知的空白字符导致了该问题。

我只是用空格替换了所有那些未知的空白字符,它对我有用。

Se 附加图像。

在此输入图像描述

在此输入图像描述