【问题标题】:Structure Schema.org in JSON-LD format for multi branch multi departments以 JSON-LD 格式构建多分支多部门的 Schema.org
【发布时间】:2017-04-11 12:14:18
【问题描述】:

我很确定这纯粹是一个语法问题,但我正在尝试为拥有 2 个分支机构且每个分支机构有 2 个主要部门的客户设置一些 JSON-LD 格式的 Schema.org。

我遇到的问题是每个部门的开放时间。这是我的代码:

{
  "@context": {
    "@vocab": "http://schema.org/"
  },
  "@graph": [{
      "@id": "http://example.com",
      "@type": "Organization",
      "name": "Group Name",
      "url": "http://example.com",
      "logo": "http://example.com/images/logo.png",
      "image": "http://example.com/images/logo.png",
      "description": "Some information about the customer",
      "currenciesAccepted": "GBP",
      "sameAs": ["https://www.facebook.com/[customers facebook page/"]
    },
    {
      "@type": "AutoDealer",
      "parentOrganization": {
        "name": "Group Name"
      },
      "name": "Banch 1",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "street",
        "addressLocality": "locality",
        "addressRegion": "region",
        "postalCode": "post code",
        "telephone": "phone number"
      },
      "department": [{
          "name": "Sales Department",
          "openingHours": ["Mo-Fr 9:00 - 19:00", "Sa 9:00 - 17:00"]
        },
        {
          "name": "Service Department",
          "openingHours": ["Mo-Fr 7:30 - 18:00", "Sa 9:00 - 12:00"]
        }
      ],
      "hasmap": "google map url"
    },
    {
      "@type": "AutoDealer",
      "parentOrganization": {
        "name": "Group Name"
      },
      "name": "Branch 2",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "street",
        "addressLocality": "locality",
        "addressRegion": "region",
        "postalCode": "post code",
        "telephone": "phone number"
      },
      "department": [{
          "name": "Sales Department",
          "openingHours": ["Mo-Fr 9:00 - 19:00", "Sa 9:00 - 17:00"]
        },
        {
          "name": "Service Department",
          "openingHours": ["Mo-Fr 7:30 - 18:00", "Sa 9:00 - 12:00"]
        }
      ],
      "hasmap": "Google map url"
    }
  ]
}

当我在谷歌的结构化数据测试工具上测试它时,我得到了错误:

Google 无法识别 Organization 类型的对象的属性 openingHours

【问题讨论】:

  • 这已经很晚了,但是 LocalBusiness 标记有一个“branchCode”字段

标签: schema.org json-ld


【解决方案1】:

openingHours 属性可用于CivicStructureLocalBusiness 类型。

您没有指定要为其提供此属性的节点的类型:

{
  "name": "Sales Department",
  "openingHours": ["Mo-Fr 9:00 - 19:00", "Sa 9:00 - 17:00"]
},

Google 的测试工具似乎假定此节点的类型为 Organization,因为它是 department 属性所期望的值。因为openingHours 不能在Organization 上使用(但在其子类型LocalBusiness 上),Google 给出了这个错误。

所以要解决这个问题,请添加预期的类型,例如类似:

{
  "@type": "AutoDealer",
  "name": "Sales Department",
  "openingHours": ["Mo-Fr 9:00 - 19:00", "Sa 9:00 - 17:00"]
},

【讨论】:

  • 太棒了。谢谢你的帮助。现在说得通了。
  • @Strontium_99:不客气。顺便说一句,您可以考虑仅提供 Organization 作为顶级项目,并使用其 @987654323 @ 属性以连接到两个 AutoDealer 项目。如果由于某种原因无法做到这一点,那么您可以使用 @id 为每个节点指定一个标识符,并使用它来传达您正在谈论的是同一个组织。
  • 这更有意义。我会从互联网上的一篇文章中拼凑起来,因此是多余的@graph。但是您的建议感觉更合乎逻辑。谢谢乌诺。你是明星。
猜你喜欢
  • 2015-08-10
  • 1970-01-01
  • 2018-05-26
  • 1970-01-01
  • 1970-01-01
  • 2020-01-25
  • 2019-04-29
  • 1970-01-01
  • 2018-11-13
相关资源
最近更新 更多