Schema.org-嵌套事件

问题描述 投票:0回答:1

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

我正在根据我所拥有的数据,寻求有关我究竟需要如何格式化JSON的澄清。

我有很多活动。它们具有开始和结束日期/时间。它们具有名称/标题和描述。

每个事件都有“子事件”。例如:

Russian Ballet
  - Russian Ballet Monday
  - Russian Ballet Tuesday

Arts Exhibition
  - Arts Exhibition Thursday

事件及其“子事件”是一次性事件。

我看过subEventeventScheduleoffers(每个子事件都是票-尽管没有价格)

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

谢谢

schema.org
1个回答
0
投票

通常,一个适合所有情况的示例为您提供一个适合所有情况的示例(这与数据结构有关)。

概述示例两个嵌套对象(事件内的子事件)

<script type="application/ld+json">
{
  "@context":"http://schema.org",
     "@type":"Event",
     "name":"Event name - Playstation FIFA World Cup 2020",
     "subEvent":[
        {
           "@type":"Event",
           "name":"sub-event name"
        },
        {
           "@type":"Event",
           "name":"sub-event name"
        }
     ]
  }
}
</script>

概述示例三个嵌套对象(事件内子事件内的eventSchedule)

<script type="application/ld+json">
{
  "@context":"http://schema.org",
     "@type":"Event",
     "name":"Event name - Playstation FIFA World Cup 2020",
     "subEvent":[
      {
         "@type":"Event",
         "name":"sub-event name",
         "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 PlayStation tournament事件和3个子事件

  • 季度末活动日
  • 半决赛活动日
  • 最终活动日

您可以为每个事件添加属性,除了属性。


<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Event",
    "name": "Event name - Playstation 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>

enter image description here

嵌套

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

© www.soinside.com 2019 - 2024. All rights reserved.