将Schema.org属性类型嵌套在JSON-LD中的对象类型中的正确方法是什么

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

问题:

如何在Schema.org代码中将property Object Type类型嵌套在JSON-LD中?

上下文:

我有一个网站,其中包含有关人物传记的网页。我有一个针对JSON-LD对象类型的经过验证的Schema.org Person代码。

我想扩展代码以包括在某个角色之前和之后的人员。例如,如果页面与城市的市长有关,那么我想添加前任和后任市长。

我可以找到的最接近的属性是上一个市长的followslink)和下一个市长的followeelink)。

问题:

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>

我厌倦了其他几种变体,但都导致了错误。是否对代码进行了可行的更正,或者实现目标的替代方法?

json schema.org
1个回答
0
投票

正如我在评论中提到的,我认为不适合您使用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>
© www.soinside.com 2019 - 2024. All rights reserved.