Warm tip: This article is reproduced from serverfault.com, please click

其他-如何使用JSON-LD在schema.org中使用午餐时间编写有效的开放时间

(其他 - How to write valid opening hours with lunch break in schema.org with JSON-LD)

发布于 2020-11-27 12:48:59

我在这里阅读了有关该主题的所有文章,但找不到解决方案。

我正在为一家营业时间如下的企业建立页面:

周一至周五07:00-12:00和13:00-17:00(1小时午餐休息)

我找不到一种将其写为schema.org标记的有效JSON-LD的方法。Google的丰富结果测试工具不接受我的想法,在schema.org文档中,我找不到此类情况的任何示例。

没有午餐休息时间的标准有效代码如下所示:

"openingHoursSpecification": {
"@type": "OpeningHoursSpecification",
"dayOfWeek": [
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday"
],
"opens": "07:00",
"closes": "17:00"

},

我想拥有的代码是这样的,但是我无法对其进行验证,也找不到任何示例来说明它是如何完成的。

"openingHoursSpecification": {
"@type": "OpeningHoursSpecification",
"dayOfWeek": [
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday"
],
"opens": "07:00",
"closes": "12:00",
"opens": "13:00",
"closes": "17:00"

},

感谢你对此提供的任何帮助!干杯,亚伦

Questioner
Aaron
Viewed
0
Aaron 2020-11-30 22:26:34

感谢Jay Gray的评论,在此较早的帖子中使用hoursAvailable的解决方案似乎可以正常工作。使用Google的测试工具进行了测试:

原始帖子:JSON-LD中的Schema.org OpeningHoursSpecification中包含“午休”

原始帖子中的代码:

{
"@context": "http://schema.org",
"@type": "Service",
"url": "http://www.example.com/",
"hoursAvailable": [{
    "@type": "OpeningHoursSpecification",
    "opens": "08:00",
    "closes": "13:00",
    "dayOfWeek": [{
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Monday",
        "name": "Monday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Tuesday",
        "name": "Tuesday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Wednesday",
        "name": "Wednesday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Thursday",
        "name": "Thursday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Friday",
        "name": "Friday"
    }]
},
{
    "@type": "OpeningHoursSpecification",
    "opens": "15:00",
    "closes": "20:00",
    "dayOfWeek": [{
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Monday",
        "name": "Monday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Tuesday",
        "name": "Tuesday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Wednesday",
        "name": "Wednesday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Thursday",
        "name": "Thursday"
    },
    {
        "@type": "DayOfWeek",
        "@id": "http://schema.org/Friday",
        "name": "Friday"
    }]
}]

}