Schema.org - 嵌套事件

Schema.org - nesting events

我目前正在构建一个 API,它将生成一个 JSON-LD 输出,供 schema.org 使用。

我正在寻找一些关于我需要如何根据我拥有的数据格式化 JSON 的说明。

我有一堆活动。他们有开始和结束 date/time。他们有 name/title 和描述。

每个事件都有 "sub events"。例如:

Russian Ballet
  - Russian Ballet Monday
  - Russian Ballet Tuesday

Arts Exhibition
  - Arts Exhibition Thursday

活动及其 "sub events" 是一次性活动。

我看过 subEventeventScheduleoffers(每个子事件都是一张门票 - 虽然没有价格)

我用哪个?我有点需要每个,但不确定如何嵌套事件数据

谢谢

An Event that is part of this event. For example, a conference event includes many presentations, each of which is a subEvent of the conference. https://schema.org/subEvent

总的来说,没办法给你一个例子来包罗万象。

复杂性

您可以在子事件中嵌套子事件 inside...inside...

在这个例子中 Child event one 有两个子事件。

<script type="application/ld+json">
{
  "@context":"http://schema.org",
     "@type":"Event",
     "name":"Parent event",
     "subEvent":[
        {
           "@type":"Event",
           "name":"Child event one",
           "subEvent":[
             {
               "@type":"Event",
               "name":"Grandchild one"
            },
            {
               "@type":"Event",
               "name":"Grandchild two"
            }
            ]
        },
        {
           "@type":"Event",
           "name":"Child event two"
        }
     ]
  }
}
</script>

三层嵌套对象的大纲示例

(子事件内的事件计划。事件内的子事件)

eventSchedule 数据已添加到 sub-event one(父事件的子事件)。

<script type="application/ld+json">
{
  "@context":"http://schema.org",
     "@type":"Event",
     "name":"Event name - FIFA World Cup 2020",
     "subEvent":[
      {
         "@type":"Event",
         "name":"sub-event one",
         "eventSchedule":{
            "@type":"Schedule",
            "startDate":"2017-01-01",
            "endDate":"2017-12-31",
            "repeatFrequency":"P1W",
            "byDay":"http://schema.org/Wednesday",
            "startTime":"19:00",
            "endTime":"20:00",
            "scheduleTimezone":"Europe/London"
         }
      },
      {
         "@type":"Event",
         "name":"sub-event name"
      }
     ]
    }
}
</script>

代码示例

**(缺少一些较短代码的属性)

FIFA World cup 包含 3 个子事件的事件

  • 四分之一决赛 活动日
  • 半决赛活动日
  • 决赛活动日

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Event",
    "name": "FIFA World Cup 2020",
    "startDate": "2020-09",
    "endDate": "2020-11",
    "location": {
      "@type": "Place",
      "address": {
        "@type": "PostalAddress",
        "addressLocality": "London",
        "postalCode": "80209",
        "streetAddress": "7 S. Broadway"
      },
      "name": "London Place Name"
    },
    "offers": {
      "@type": "Offer",
      "price": "13.00",
      "priceCurrency": "USD",
      "url": "http://www.ticketfly.com/purchase/309433"
    },
    "subEvent": [
    {
      "@type": "Event",
      "name": "Quarter final - FIFA World Cup 2020",
      "description": "lorem ipsum",
      "startDate": "2020-09",
      "endDate": "2020-09",
      "location": {
      "@type": "Place",
      "name": "London Place Name",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "7 S. Broadway"
        }
        }
    },
    {
      "@type": "Event",
      "name": "Semi final - FIFA World Cup 2020",
      "description": "lorem ipsum",
      "startDate": "2020-10",
      "endDate": "2020-10",
      "location": {
      "@type": "Place",
      "name": "London Place Name",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "7 S. Broadway"
        }
        }
    },
    {
      "@type": "Event",
      "name": "Final - FIFA World Cup 2020",
      "description": "lorem ipsum",
      "startDate": "2020-10",
      "endDate": "2020-10",
      "location": {
      "@type": "Place",
      "name": "London Place Name",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "7 S. Broadway"
        }
        }
    }
    ] 
  }
</script>

Google Email Markup Tester输出截图:

嵌套对象

嵌套对象的想法与 schema.org 上的任何其他嵌套数据没有区别(因此您阅读的有关此主题的每个教程都可能对您有所帮助)。 从简单的示例开始,例如: