【问题标题】:How do I separate @types into different cards using JSON-LD?如何使用 JSON-LD 将 @types 分成不同的卡片?
【发布时间】:2016-11-09 02:31:20
【问题描述】:

结构化数据测试工具不会将我的@types 分成不同的部分,而是将所有@types 放在一个主要类型中:产品。如何分离类型以便将每个类型都验证为自己的容器?

http://imgur.com/a/MhWq2(我想从第一张图片转到类似于第三张图片的内容,请原谅错误/警告)

{
  "@context": "http://schema.org",
  "@type": "Product",
  "name": "Product1",
  "image": "http://mycompany.com/logo.png",
  "color": "example",

  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "1",
    "ratingCount": "0",
    "worstRating": "1",
    "bestRating": "5"
  },
  "brand": {
    "@type": "Organization",
    "name": "Company1",
    "logo": "http://mycompany.com/logo.png"
  }

我有比这更多的标记,但我认为这足以说明我想要完成的工作。谢谢!

【问题讨论】:

  • 为什么要实现这个目标?

标签: json schema json-ld linked-data structured-data


【解决方案1】:

有几种方法可以做到这一点,但每种方法都不同,因为含义不同。

例如,如果您说的是“我的产品的 AggregateRating 为 <values> 并由某个组织进行品牌化”,那么您应说明上述内容。

或者,您可以制作多个单独的语句并将它们链接在一起。例如:

<script type="application/ld+json">
{
    "@context": {
        "@vocab": "http://schema.org/",
        "id": "@id",
        "graph": "@graph",
        "type": "@type"
    },
    "graph": [
        {
            "type": "Organization",
            "id": "#001",
            "name": "Big-Daddy",
            "image": "http://bigdaddy.com/logo.png"
        },
        {
            "type": "Product",
            "id": "#002",
            "name": "Big-2",
            "image": "http://bigdaddy.com/big-2.png",
            "brand": {
                "type": "Organization",
                "id": "#001"
            },
            "aggregateRating": {
                "type": "AggregateRating",
                "ratingValue": "3",
                "ratingCount": "20",
                "worstRating": "3",
                "bestRating": "4"
            }
        },
        {
            "type": "Product",
            "id": "#003",
            "name": "Big-3",
            "image": "http://bigdaddy.com/big-3.png",
            "brand": {
                "type": "Organization",
                "id": "#001"
            },
            "aggregateRating": {
                "type": "AggregateRating",
                "ratingValue": "3",
                "ratingCount": "20",
                "worstRating": "2",
                "bestRating": "5"
            }
        }
    ]
}
</script>

在口语模式下,这表示:“我有两种产品,每种产品的 AggregateRating 均为 &lt;values&gt;,由 Big-Daddy 品牌。”

我可以想到其他几种变体,但每种变体意味着不同。

但是,Google SDTT 承认上述示例中的两个产品。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-02
    • 1970-01-01
    • 2011-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多