What exactly are pointers in Schema.org and how to use them with JSON-LD?

*爱你&永不变心* 提交于 2019-12-12 19:18:12

问题


The schema.org docs refer sometimes to "pointers". E.g. Product schema has the property isSimilarTo.

I do understand, that I could use a Productor a Service directly. E.g.:

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "name": "BMW",
  "isSimilarTo": {
    "@type": "Product",
    "name": "Mercedes Benz"
  },
  "offers": {
    "@type": "Offer",
    "priceCurrency": "EUR",
    "price": "100000.00"
  }
}
</script>

Is this the only and the correct way using and interpreting the term 'pointer' in this context? For a pointer, I would rather expect some value (an ID or an URL or similar) just pointing to another product or service.


回答1:


Your example is correct, and it follows Schema.org’s recommendation for the expected value of the isSimilarTo property. But Schema.org allows URI values for each property, even for those that don’t explicitly list URL as expected value.

So you could also use:

  "isSimilarTo": {
    "@id": "https://example.com/products/mercedes-benz#this"
  },

Note that consumers (like Google) don’t necessarily follow these references. You could also use both ways: provide the data (or some of it) on the current page, and refer to the item’s URI:

   "isSimilarTo": {
    "@id": "https://example.com/products/mercedes-benz#this",
    "@type": "Product",
    "name": "Mercedes Benz",
    "url": "https://example.com/products/mercedes-benz"
  },


来源:https://stackoverflow.com/questions/41697456/what-exactly-are-pointers-in-schema-org-and-how-to-use-them-with-json-ld

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!