【问题标题】:Error in SDTT for an array of hasOccupation objects using Roles: "hasOccupation is not a known valid target type for the hasOccupation property"使用角色的 hasOccupation 对象数组的 SDTT 错误:“hasOccupation 不是 hasOccupation 属性的已知有效目标类型”
【发布时间】:2018-12-15 11:51:08
【问题描述】:

使用 JSON-LD 语法和 Schema.org 词汇,根据 Schema.org's Occupation example 4,以下应该是有效的,但不是。

{
    "@context": "http://schema.org",
    "@type": "Person",
    "name": "Jane Smith",
    "sameAs": "http://en.wikipedia.org/wiki/Jane_Smith",
    "worksFor": {
        "@type": "Organization",
        "name": "McKinsey & Company",
        "url" : "http://www.mckinsey.com"
    },
    "hasOccupation": [ {
          "@type": "Role",
          "hasOccupation": {
            "name": "Management Consultant"
          },
          "startDate": "2016-04-21"
        }, {
          "@type": "Role",
          "hasOccupation": {
            "name": "Chief Strategic Officer"
          },
          "startDate": "2013-11-14",
          "endDate": "2016-03-22"
        }, {
          "@type": "Role",
          "hasOccupation": {
            "name": "Vice President of Sales"
          },
          "startDate": "2009-09-20",
          "endDate": "2013-10-14"
        }
    ]
}

通过 Google 的Structured Data Testing Tool

hasOccupation 不是 hasOccupation 属性的已知有效目标类型。

【问题讨论】:

    标签: schema.org json-ld


    【解决方案1】:

    您没有在Role 中提供hasOccupation 值的类型。它需要一个 Occupation 值。

    所以这个

    "hasOccupation": {
      "name": "Management Consultant"
    }
    

    应该变成这个

    "hasOccupation": {
      "@type": "Occupation",
      "name": "Management Consultant"
    }
    

    (其他情况相同。)

    【讨论】:

    • 这似乎是正确的答案,尽管 SDTT 仍然给出错误。尝试将其粘贴到 SDTT pastebin.com/MxG2ULGr
    • @Orun:您使用了错误的引号(pastebin 页面以黑色而不是蓝色突出显示受影响的行)。如果您修复此问题,SDTT 仍会报告错误,但这些错误属于不同类别(缺少属性 → 但 Schema.org 不需要它们,仅在获取特定的 Google 搜索结果功能时需要)。
    • 哇,你说得对。不敢相信我没有看到。在我的编辑器中的默认等宽字体中并没有清楚地显示差异。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 2010-11-23
    • 1970-01-01
    • 2014-06-27
    相关资源
    最近更新 更多