我目前正在构建一个API,该API将生成将由schema.org使用的JSON-LD输出。
我正在根据我所拥有的数据,寻求有关我究竟需要如何格式化JSON的澄清。
我有很多活动。它们具有开始和结束日期/时间。它们具有名称/标题和描述。
每个事件都有“子事件”。例如:
Russian Ballet
- Russian Ballet Monday
- Russian Ballet Tuesday
Arts Exhibition
- Arts Exhibition Thursday
事件及其“子事件”是一次性事件。
我看过subEvent
,eventSchedule
和offers
(每个子事件都是票-尽管没有价格)
我使用哪个?我有点需要每个,但不确定如何嵌套事件数据
谢谢
通常,一个适合所有情况的示例为您提供一个适合所有情况的示例(这与数据结构有关)。
<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>
<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>
嵌套对象的想法与schema.org上的任何其他嵌套数据都没有区别(因此,您阅读的有关该主题的每个教程都可能对您有所帮助)。