如何组合2个JSON-LD模式类型?

时间:2015-08-20 14:55:38

标签: json schema.org jsonschema

我需要将两组JSON-LD组合在一起,以便它们位于同一页面上。无论是个人还是当地企业。目标不是必然与2相关,但它们一起出现。

以下是第1组:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Person",
  "name": "John Doe",
  "jobTitle": "Graduate research assistant",
  "affiliation": "University of Dreams",
  "additionalName": "Johnny",
  "url": "http://www.example.com",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "1234 Peach Drive",
    "addressLocality": "Wonderland",
    "addressRegion": "Georgia"
  }
}
</script>

以下是第2组:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Restaurant",
  "address": {
    "@type": "PostalAddress",
    "addressLocality": "Sunnyvale",
    "addressRegion": "CA",
    "postalCode": "94086",
    "streetAddress": "1901 Lemur Ave"
  },
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4",
    "reviewCount": "250"
  },
  "name": "GreatFood",
  "openingHours": [
    "Mo-Sa 11:00-14:30",
    "Mo-Th 17:00-21:30",
    "Fr-Sa 17:00-22:00"
  ],
  "priceRange": "$$",
  "servesCuisine": [
    "Middle Eastern",
    "Mediterranean"
  ],
  "telephone": "(408) 714-1489",
  "url": "http://www.dishdash.com"
}
</script>

现在,第1组和第2组使用Google's Structured Data Testing Tool单独验证

Group 1

Group 2

尝试将这些组合在一起,只有顶级组验证。另一个没有表现出来。

Combined

帮助!这两个组如何以正确的方式组合?

2 个答案:

答案 0 :(得分:2)

acBoth是否可以嵌套在http://schema.org/WebPage中,mainEntity可以设置为Person,mentions可以设置为Restaurant。

人与餐厅之间可能存在某种关系,可以提供更好的契合度,例如,人可能是关于餐厅的网页的作者,或者是网页的问责人,在餐厅吃饭(一个动作) ),是一名员工,创始人或审查过。

答案 1 :(得分:1)

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": ["ItemList", "CreativeWork"],
  "name": "Top 5 covers of Bob Dylan Songs",
  "author": "John Doe",
  "about": {
    "@type": "MusicRecording",
    "byArtist": {
      "@type": "MusicGroup",
      "name": "Bob Dylan"
    }
  },