问题:
如何在Schema.org代码中将property
Object Type
类型嵌套在JSON-LD
中?
上下文:
我有一个网站,其中包含有关人物传记的网页。我有一个针对JSON-LD
对象类型的经过验证的Schema.org Person代码。
我想扩展代码以包括在某个角色之前和之后的人员。例如,如果页面与城市的市长有关,那么我想添加前任和后任市长。
我可以找到的最接近的属性是上一个市长的follows
(link)和下一个市长的followee
(link)。
问题:
follows
属性已得到验证,没有任何问题,但是如果将followee
直接放置在Person
类型的下面,因为它需要使用FollowAction
类型,所以会出现错误。
The property @followee is not recognized by Google for an object of type Person.
解决方法:
我试图嵌套代码,但无法成功完成。例如:
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Person",
"name": "john Citizen",
{
"@context": "http://schema.org/",
"@type": "FollowAction",
"followee": {
"@type": "Person",
"name": "Steve"
}
}
}
</script>
我厌倦了其他几种变体,但都导致了错误。是否对代码进行了可行的更正,或者实现目标的替代方法?
正如我在评论中提到的,我认为不适合您使用Follows或FollowAction。
出于学术目的,有一种方法可以在人体内标记FollowAction。由于FollowAction可以通过其代理引用Person,但反之则不能,因此您可以使用反向属性来指示一种向后引用:
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Person",
"name": "john Citizen",
"@reverse": {
"agent":
{
"@type": "FollowAction",
"followee": {
"@type": "Person",
"name": "Steve"
}
}
}
}
</script>