JSON-LD:“数组声明中缺少','或']'。在结束标签上

时间:2019-05-24 16:12:13

标签: json-ld

我正在使用Schema.org标记本地业务页面。我正在尝试使用JSON-LD语法应用openingHoursSpecification值,但是在通过SDTT验证时收到语法错误。

错误出现在我的代码的第67行上,该代码仅包含结束</script>标记。

我尝试将第63行的],移动到第66行,以确保openscloses值/对象是openingHoursSpecification数组的一部分,但是我只会收到更多错误。我对</script>结束标记与我的代码有什么关系感到困惑。

示例代码:

{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "image": "http://www.website.com/example.png",
  "@id": "http://www.website.com",
  "name": "ExampleBusiness",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "xxxxxxxxxxxxxxxx",
    "addressLocality": "Houston",
    "addressRegion": "Texas",
    "postalCode": "xxxxx",
    "addressCountry": "United States"
  },
  "review": {
    "@type": "Review",
    "reviewRating": {
      "@type": "Rating",
      "ratingValue": "4",
      "bestRating": "5"
    },
    "author": {
      "@type": "Person",
      "name": "xxxxxx"
    }
  },
  "geo": {
    "@type": "GeoCoordinates",
    "latitude": xx.xx,
    "longitude": -xx.xx
  },
  "url": "http://www.example.com",
  "telephone": "+0000000000",
  "openingHoursSpecification": [
    {
      "@type": "OpeningHoursSpecification",
      "dayOfWeek": [
        "Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday"
      ],
      "opens": "08:00",
      "closes": "17:00"
    }]

SDTT中显示错误:

screenshot

2 个答案:

答案 0 :(得分:1)

除非发布此问题时仅是复制粘贴错误,否则看起来您只是缺少右括号'}'。您在第67行看到错误,因为它在尝试解析JSON时到达了script标记,因为没有终止括号来终止解析器。

应该能够只添加'}'。

我经常用来测试看起来格式错误的JSON的一个网站是https://jsonlint.com/

答案 1 :(得分:1)

您以{打开JSON-LD,但它没有以}结尾。因此,您需要在末尾添加一个}

  }]
}

另一个错误:您需要引用所有字符串值。所以,这

"latitude": xx.xx,
"longitude": -xx.xx

应该是这个

"latitude": "xx.xx",
"longitude": "-xx.xx"