用于多分支多部门的JSON-LD格式的结构Schema.org

时间:2017-04-11 12:14:19

标签: schema.org json-ld

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

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

{
  "@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的结构化数据测试工具上测试时,我收到错误:

  

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

1 个答案:

答案 0 :(得分: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"]
},