我有一个关于在另一个 JSON-LD schema.org 标记中引用 JSON-LD schema.org 标记的问题。我有一个包含主要事件的页面,位于 http://event.com/
这是它的 JSON-LD 标记。
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
主事件有多个子事件位于例如
http://event.com/sub-event-1/
这是为此的 JSON-LD 标记:<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
我要做的是将子事件标记为主要事件的一部分。是否可以创建从主事件到子事件的引用?像这样的东西:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
superEvent {
"url": "http://event.com/"
}
}
</script>
如果可能的话,什么是正确的引用标记。我找不到任何关于它的信息。
或者是否需要像这样在每个子事件中嵌入 MainEvent:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
},
"superEvent": {
"@type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
}
</script>
最佳答案
您可以通过给它一个 URI 来标识一个节点,在 @id
中指定。关键词。此 URI 可用于引用该节点。
请参阅 JSON-LD 规范中的“Node Identifiers”部分。
所以你的主要事件可以获得 URI http://example.com/2016-04-21#main-event
:
<script type="application/ld+json">
{
"@id": "http://example.com/2016-04-21#main-event",
"@context": "http://schema.org",
"@type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00"
}
</script>
您可以将此 URI 作为子事件的
superEvent
的值。属性(property):<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"superEvent": { "@id": "http://example.com/2016-04-21#main-event" }
}
</script>
(你当然也可以给你的子事件一个
@id
。这将允许你和其他人识别/引用这个子事件。)
关于Schema.org JSON-LD 引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34761970/