如何使用JSON-LD将@types分成不同的卡?

时间:2016-07-06 21:35:22

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

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

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"
  }

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

1 个答案:

答案 0 :(得分:1)

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

例如,如果您正在说出句子&#34;我的产品的AggregateRating为<values>且由组织&#34;标记,您可以说明上述内容。

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

<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>

在发言模式中,这说:&#34;我有两个产品,每个产品的AggregateRating为<values>,由Big-Daddy打上品牌。&#34;

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

但是,Google SDTT在上面的例子中承认了两个产品。